mock-serve
Mock -serve is a native front-end mock data service
In a separate architecture, front-end developers often need to simulate data, usually in the following ways:
- Write to death in code
- Through the Mock. Js
- Through the Easy – the Mock
The latter two are good solutions, but depending on the environment of each developer, there may be some situations, such as when the Internet is down, easy-mock is not suitable, but you might say that you can use mock. js instead. Mock. Js is no longer available when we need to look at incoming and callback arguments in the browser’s network
compromise
Build a local simulation service based on Node so that we can solve the above problems
File structure
├─ SRC ├─ Data ├─ Router ├─ index.js import fileCopy the code
usage
# install dependencies
npm install
The default address for starting the service is http://localhost:3000
npm run mock
Configure the simulation data- Create your own mock data file in the data directory - configure the API addresses you want to block in the routing file - wait for the service to hot restartCopy the code
The characteristics of
- Rules that support MockJs write mock data
- Cross-domain access is supported