Skip to content

Latest commit

 

History

History
82 lines (64 loc) · 3.54 KB

README.md

File metadata and controls

82 lines (64 loc) · 3.54 KB

WxMock

微信小程序 - 模拟数据工具

使用方法

使用代码片段分享

wechatide://minicode/wCHxXXmf6OYz

var Mock = require("./utils/WxMock.js"); 
    1. 在app.js中书写需要模拟的接口及返回结构
 Mock.mock('https://xxx.com/users',{
        "code":200,
        "data|1-20":[
            {
                "name":function() {
                  return Mock.Random.cname()
                },
                "lastLogin":function() {
                  return Mock.Random.datetime()
                }
            }
        ]
 })
  Mock.mock('https://xxx.com/user/delete',{
         "code":200,
         "message":"s删除成功"
  })
    1. 只要在 wx.request 中使用url为 mock对应的地址 就会返回响应mock数据
wx.request({
  url: 'https://xxx.com/users',
  success:function(res){
    console.log('https://xxx.com/users',res);
  }
})

Mock.js 使用方式见 http://mockjs.com/examples.html

Mock.js

Build Status GitHub version NPM version spm package Dependency Status Bower version Views in the last 24 hours

Mock.js is a simulation data generator to help the front-end to develop and prototype separate from the back-end progress and reduce some monotony particularly while writing automated tests.

The official site: http://mockjs.com

Features

  • Generate simulated data according to the data template
  • Provide request/response mocking for ajax requests with jQuery and KISSY
  • Generate simulated data according to HTML-based templates

Questions?

If you have any questions, please feel free to ask through New Issue.

Reporting an Issue

Make sure the problem you're addressing is reproducible. Use http://jsbin.com/ or http://jsfiddle.net/ to provide a test page. Indicate what browsers the issue can be reproduced in. What version of Mock.js is the issue reproducible in. Is it reproducible after updating to the latest version?

License

Mock.js is available under the terms of the MIT License.

Bitdeli Badge