1234567891011121314151617181920212223 |
- const Mock = require('mockjs')
- /**
- * 引入需要的mock模块
- * 每个mock模块只需暴露一个默认的接口
- * 暴露的模块中的元素,必须每个带有url,methods,callback
- */
- const apiModules = ['list']
- let API = {}
- apiModules.map((item) => {
- let apiObject = require(`./modules/${item}`)
- API = Object.assign(API, apiObject)
- })
- let mockObject = Object.values(API)
- mockObject.map((item) => {
- Mock.mock(item.url, item.methods, item.callback)
- })
|