当前位置:网站首页>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 ) )
边栏推荐
- mq的学习
- mysql 最大建议行数2000w,靠谱吗?
- Personal blog applet
- 2022 supplementary questions for the first session of Niuke multi school
- Feign call exception [running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = n]
- 数据库高级学习笔记--存储函数
- OSS直连上传-Rails服务实践
- 【广西大学】考研初试复试资料分享
- JDBC连接数据库
- Analysis of the internal principle of ArrayList
猜你喜欢

Standing on the shoulders of big men, you can see further

Basic operation of MATLAB

How promise instance solves hell callback

Detailed explanation of various types of files in MySQL

多线程一定能优化程序性能吗?

Create SSL certificate using OpenSSL

业务可视化-让你的流程图'Run'起来(4.实际业务场景测试)

Regular expressions for positive and negative values

软件测试与质量学习笔记2----黑盒测试

ShardingSphere简介(一)
随机推荐
Retrofit source code analysis
树上启发式合并
matlab基本操作
[log] what does a log do? What is a log factory? Configuration and use of log4j? log4j. Properties file configuration, log4j jar package coordinates
Leetcode - hashtable topic
[high number] high number plane solid geometry
使用Xposed对软件进行破解
Changes in the relationship between data and application in IT industry
软件测试与质量学习笔记1---黑盒测试
2022 supplementary questions for the first session of Niuke multi school
脉冲风采|Committer 专访——腾讯工程师张大伟喊你吃“螃蟹”啦
对话MySQL之父:代码一次性完成才是优秀程序员
数据库核心体系
Analysis of HashSet internal principle
ArrayList内部原理解析
使用 OpenSSL 创建ssl证书
Regular expressions for positive and negative values
MATLAB的符号运算
3分钟告诉你如何成为一名黑客|零基础到黑客入门指南,你只需要掌握这五点能力
View的工作原理