JSFiddle - React, Tailwind, and code Playground
HTML
<!-- (必选)加载 Mock -->
<script src="http://mockjs.com/dist/mock.js"></script>
JavaScript
// Mock.mock(rurl, function(options))
Mock.mock(/\.json/, function (options) {
return {
detail: {
id: 69,
title: 'detail title',
workData: {
'data|3': [
{
id: 100,
title: 'work title',
author: {
name: 'Steve'
}
}
]
}
}
}
})
$.ajax({
url: 'hello.json',
dataType: 'json'
}).done(function(data, status, jqXHR) {
$('<pre>').text(JSON.stringify(data, null, 4))
.appendTo('body')
})