Vue-admin工作整理(十七):Mock模拟Ajax请求

思路:使用Mock拦截actions请求,通过 Mock.mock(//getUserInfo/, 'post', getUserInfo) 进行拦截标示,然后将内容返回

export const getUserInfo = (options) => {
  console.log(options)
  // return {
  //   name: '小鸟'
  // }
  // return {
  //   name: 'Robin'
  // }

  // const template = { // 模版对象
  //   'str|2-4': 'Cristin', // 传一个属性名为str的 最小重复次数大于2最大重复次数小于4的string数据,string 数据值为 Cristin
  //   'name|3': 'Cristin', // String类型的属性,指定重复加载次数:3
  //   'age|+2': 18 // 数字类型的属性,自动+2,初始值为 18
  // }
  // let i = 3
  // let arr = []
  // while (i--) {
  //   arr.push(template)
  // }
原文地址:https://www.cnblogs.com/cristin/p/9642965.html