2019-08-07 easyMock 的使用

2019-08-28 11:23:24 浏览数 (1)

Snipaste_2019-08-07_17-19-26.png

操作步骤.gif

  • 使用模拟数据,用来调试前端页面
  • 根据不同的page 返回不同的数据
代码语言:javascript复制
{
  success: true,
  data: {

    anxun: function({
      _req,
      Mock

    }) {
      //  post 请求   get 就是req.query   
      if (_req.body.page % 2 == 0) {

        var arr = [];
        for (var i = 0; i < 10; i  ) {
          var obj = {

            alias: "威海林",
            company: "威海城市",
            createTime: "2019-07-17 09:57:51",
            creator: "",
            creatorId: "",
            email: "",
            id: 10078,
            modifiedTime: "2019-07-17 10:30:07",
            modifier: "胡博伦",
            modifierId: 100019,
            nickname: "启林",
            phone: "13300000000",
            city: "广东省-深圳市-龙岗区",
            status: 1,
            statusName: "未激活"



          };
          arr.push(obj)

        };



        return arr;
      } else {
        return [{
          alias: "威海林",
          company: "威海城市",
          createTime: "2019-07-17 09:57:51",
          creator: "",
          creatorId: "",
          email: "",
          id: 10078,
          modifiedTime: "2019-07-17 10:30:07",
          modifier: "胡博伦",
          modifierId: 100019,
          nickname: "启林",
          phone: "13300000000",
          city: "广东省-深圳市-龙岗区",
          status: 1,
          statusName: "未激活"
        }, '234', "123", '234', ]
      }
    }

  }
}

Snipaste_2019-08-07_17-28-52.png

0 人点赞