当前位置:网站首页>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 ) )
边栏推荐
猜你喜欢

MATLAB的实时编辑器

SQL server, MySQL master-slave construction, EF core read-write separation code implementation

Go language slice vs array panic runtime error index out of range problem solving

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

NET 3行代码实现文字转语音功能
C form application uses object binding DataGridView data binding

Real time editor of MATLAB

脉冲风采|Committer 专访——腾讯工程师张大伟喊你吃“螃蟹”啦

matlab基本操作

网络工程——软科中国大学专业排名
随机推荐
My vivado practice - single cycle CPU instruction analysis
Source code analysis of view event distribution mechanism
Go language slice vs array panic runtime error index out of range problem solving
MySQL中各类型文件详解
Machine learning (10) -- hypothesis testing and regression analysis
Buckle 376 swing sequence greedy
2.9.5 Ext JS的Object类型处理及便捷方法
HashSet内部原理解析
How promise instance solves hell callback
什么是跨域?如何解决请跨域问题?
Network engineering -- ranking of Chinese universities in Soft Science
Shell implements the backup / recovery / migration functions of harbor v1/v2
Window source code analysis (II): the adding mechanism of window
树上启发式合并
C# 之 方法参数传递机制
数据库核心体系
Source code analysis of activityrouter
3分钟告诉你如何成为一名黑客|零基础到黑客入门指南,你只需要掌握这五点能力
Analysis of the internal principle of ArrayList
Changes in the relationship between data and application in IT industry