Skip to content

Instantly share code, notes, and snippets.

@shawndxl
Last active July 16, 2016 07:03
Show Gist options
  • Save shawndxl/a5e0f67bf1d518aeec698015564037b4 to your computer and use it in GitHub Desktop.
Save shawndxl/a5e0f67bf1d518aeec698015564037b4 to your computer and use it in GitHub Desktop.
js pugin: MockJS

Js Plugin MockJs Useage

  • install
bower intall github:mock.git
  • link
<script src=''></script>
  • useage
Mock.setup({
  timeout: '200-600'
});

var regExp = /index.php/;
Mock.mock(regExp, function (options) {
  console.log(options);
  return Mock.mock({
    "status": 200,
    "desc": "success",
    "data": {
      integral: 201,
      ranking: {
        '1|10': [{
          "user_id|5000000-5001000": 0,
          "nickname": '@cname',
          "integral|1-1000": 0,
          "sex|0-1": 1
        }],
        '2|10': [{
          "user_id|5000000-5001000": 0,
          "nickname": '@cname',
          "integral|1-1000": 0,
          "sex|0-1": 1
        }],
        '3|10': [{
          "user_id|5000000-5001000": 0,
          "nickname": '@cname',
          "integral|1-1000": 0,
          "sex|0-1": 1
        }]
      }
    }
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment