mock使用
# 使用
# 方式一:返回方法
import Mock from "mockjs";
export default {
'GET /mock/eac-server/api/v1/responsible_person/edit': (req,res) => {
res.status(200).send(
Mock.mock(
{
code: 200,
msg: 'success',
data: {
"record_id": "@guid",
"company_id": "@guid",
"director": "@cname",
"deputy_director": "@cname",
"member": "@ctitle(3, 20)",
"responsibility_person": "@cname",
"charge_person": "@cname",
"full_time_personnel": "'@cname",
"responsible_person_project|3-10": [
{
"record_id":"@guid",
"responsible_person_id": "@guid",
"name": "@name",
"management_unit_responsible_person": "@ctitle(3, 20)",
"management_unit_management_person": "@ctitle(3, 20)",
"general_contractor_responsible_person": "@cname",
"general_contractor_management_person": "@cname"
}
],
},
}
)
)
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 方式2:直接返回mock
这样第二次请求会出现304
import Mock from "mockjs";
export default {
'GET /mock/eac-server/web/v1/knowledge/my/list': Mock.mock(
{
code: 0,
msg: 'success',
data: {
'current|20-100': 1,
'list|2-10': [
{
id:'@guid',
name:'@cname',
created_by:'@cname',
created_at:'@now',
"size|1-9000": 10,
'type|1':[1,2],
'number_downloads|1-1000':1,
sharing_scope:['尼诺','高新控股'],
}
],
'total|20-100': 30
},
}
)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
编辑 (opens new window)
上次更新: 2023/07/13