K-Mcok
Imitate the source of the other way eg: json|jsonp|client_api Edit
- rewriting XHR: support all XHR MOCK
- JSONP: support jquery jsonp
- client_api: can rewriting client api
Examples
tips: Via the url contains debug = true, decide whether to open the K - Mock
//set mock data and apiwindowK_Mock_Demo = Client: { windownative_my = {} windownative_my{ ... }; } Ajax: data: 'http://k-report.aaaa.com/v1': success: v1: 1 //use mockvar _k_mock = windowK_Mock_Demo $;
Demo
read ./Demo/
Installation
<script src="./publish/js/index.js"></script>
And it's just as easy with npm:
npm i --save npm install k-mock
API
var _k_mock = windowK_Mock_Demo_k_mockmock_status === true //ture if
Tips
JSONP just support suceess callback
if you want use json
you can dataType: _k_mock.mock_status ? "json" : "jsonp",
Thanks
- https://github.com/badoo/MockJS: K-Mock reference Mock.js rewriting XHR