|
- mockjs拦截my.json、/my请求,返回mock数据
- 复制代码
- Mock.mock(/\/my/, {
- 'list|1-10': [{
- 'id|+1': 1,
- 'email': '@EMAIL'
- }]
- });
- Mock.mock(/my.json/, {
- 'list|1-10': [{
- 'id|+1': 1,
- 'email': '@EMAIL'
- }]
- });
- $.ajax({
- url: '/my',
- dataType: 'json',
- success: function(data, status, jqXHR) {
- $('<pre>').text(JSON.stringify(data, null, 4)).appendTo('body');
- }
- });
- $.ajax({
- url: 'my.json',
- dataType: 'json',
- success: function(data, status, jqXHR) {
- $('<pre>').text(JSON.stringify(data, null, 4)).appendTo('body');
- }
- });
复制代码
|
|