$ui/utils/mock

模拟数据Mockjs处理模块

Source:
Author:
  • 陈华春

(require("$ui/utils/mock"))(item)

Source:

根据mock配置规则,设置拦截请求返回模拟数据

Example
import mock from '@/utils/mock'
mock({
 title: 'GET_USERS',
 url: GET_USERS,
 method: 'get',
 params: {},
 template: {
   code: 0,
   msg: '获取成功',
   data: {
     'id': '@guid',
     'name': '@cname'
   }
  }
})
Parameters:
Name Type Description
item Object

mock规则对象

Properties
Name Type Attributes Description
title String

规则描述文字

url String

请求url地址

method String

请求方法类型,如:get post head put patch delete options

params Object <optional>

请求url查询参数对象

template Object | function

模拟数据模板