No Description

index.js 476B

1234567891011121314151617181920212223
  1. const Mock = require('mockjs')
  2. /**
  3. * 引入需要的mock模块
  4. * 每个mock模块只需暴露一个默认的接口
  5. * 暴露的模块中的元素,必须每个带有url,methods,callback
  6. */
  7. const apiModules = ['list']
  8. let API = {}
  9. apiModules.map((item) => {
  10. let apiObject = require(`./modules/${item}`)
  11. API = Object.assign(API, apiObject)
  12. })
  13. let mockObject = Object.values(API)
  14. mockObject.map((item) => {
  15. Mock.mock(item.url, item.methods, item.callback)
  16. })