当前位置:网站首页>Mock.js
Mock.js
2022-07-28 09:46:00 【Pickled vegetables】
Mock.mock()
One 、 Parameters
Mock.mock( rurl?, rtype?, template|function( options ) )
among :
1.rurl: Optional
Express Need to intercept URL, It can be URL String or URL Regular . for example //domain/list.json/、‘/domian/list.json’.
2.rtype: Optional
Means something that needs to be intercepted Ajax Request type . for example GET、POST、PUT、DELETE etc. .
3.template: Optional
Represents a data template , It can be Object or string . for example { ‘data|1-10’:[{}] }、‘@EMAIL’.
4.function(options): Optional
Represents the function used to generate response data .
5.options:
Point to... Of this request Ajax Option set , contain url、type and body Three attributes , See XMLHttpRequest standard .
Two 、 Examples of different parameters
(1) Generate simulation data according to data template .
Mock.mock( template )
(2) Record data template . When Intercept match rurl Of Ajax When asked , According to the data template template Generate simulation data , And as a The response data return .
Mock.mock( rurl, template )
(3) Record Function used to generate response data . When a match is intercepted rurl Of Ajax When asked , function function(options) Will be carried out , And return the execution result as response data .
Mock.mock( rurl, function( options ) )
(4) Record data template . When a match is intercepted rurl and rtype Of Ajax When asked , According to the data template template Generate simulation data , And return... As response data .
Mock.mock( rurl, rtype, template )
(5) Record the function used to generate response data . When a match is intercepted rurl and rtype Of Ajax When asked , function function(options) Will be carried out , And return the execution result as response data .
Mock.mock( rurl, rtype, function( options ) )
边栏推荐
- Opencv installation configuration test
- [autosar-rte] - 3-runnable and its task mapping mapping
- Scalable search bar, imitating Huawei application market
- Window source code analysis (IV): window deletion mechanism
- [gossip] the development of programmers needs two abilities most
- [high number] high number plane solid geometry
- 数据泄漏、删除事件频发,企业应如何构建安全防线?
- [multithreading] the underlying principle of println method
- [summary of leetcode weekly competition] the 83rd fortnight competition of leetcode (7.23)
- Arouter source code analysis (III)
猜你喜欢

Introduction to shardingsphere's concept of sub database and sub table (2)

Method parameter transfer mechanism of C #

The maximum recommended number of rows for MySQL is 2000W. Is it reliable?
![[high number] high number plane solid geometry](/img/fc/da6aefed48f4adbaf58995b5e8fa46.png)
[high number] high number plane solid geometry

【广西大学】考研初试复试资料分享

Network engineering -- ranking of Chinese universities in Soft Science

opencv安装配置测试

Business visualization - make your flowchart'run'(4. Actual business scenario test)

OSS直连上传-Rails服务实践

478-82(56、128、718、129)
随机推荐
业务可视化-让你的流程图'Run'起来(4.实际业务场景测试)
LinkedList内部原理解析
Business visualization - make your flowchart'run'(4. Actual business scenario test)
数据库那么多概念性的东西怎么学?求方法
[autosar-rte] - 3-runnable and its task mapping mapping
ECCV 2022 | 无需微调即可推广!基于配准的少样本异常检测框架
ArrayList内部原理解析
[Download] several tools for brute force cracking and dictionary generation are recommended
Detailed explanation of various types of files in MySQL
Source code analysis of view event distribution mechanism
478-82(56、128、718、129)
express搭建一个简易的本地后台(一)
Shell implements the backup / recovery / migration functions of harbor v1/v2
Method parameter transfer mechanism of C #
数据库高级学习笔记--系统包
FPGA development learning open source website summary
Go language slice vs array panic runtime error index out of range problem solving
Window源码解析(三):Window的更新机制
21 day learning challenge - "AUTOSAR from introduction to mastery - practical part"
How does gbase 8A use preprocessing to quickly insert data?