Skip to content

Commit 7e3440d

Browse files
authored
Add files via upload
1 parent 30463c5 commit 7e3440d

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

mock/user-data.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = [{
2+
"_id": "540000198212061166",
3+
"username": "冯霞",
4+
"age": 28
5+
}, {
6+
"_id": "360000198410117032",
7+
"username": "张静",
8+
"age": 28
9+
}, {
10+
"_id": "510000198812169757",
11+
"username": "唐霞",
12+
"age": 23
13+
}, {
14+
"_id": "540000201002128195",
15+
"username": "陆平",
16+
"age": 24
17+
}, {
18+
"_id": "990000200708037438",
19+
"username": "乔涛",
20+
"age": 23
21+
}]

mock/user.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const Mock = require('mockjs')
2+
const fs = require('fs')
3+
4+
const {
5+
users
6+
} = Mock.mock({
7+
"users|5": [{
8+
"_id": "@id()",
9+
"username": "@cname()",
10+
"age|20-30": 30
11+
}]
12+
})
13+
14+
const res = 'module.exports = ' + JSON.stringify(users)
15+
// 新建文件,写入数据
16+
fs.writeFile('./user-data.js', res, function(error) {
17+
if (error) {
18+
console.log('写入失败')
19+
} else {
20+
console.log('写入成功了')
21+
}
22+
})

0 commit comments

Comments
 (0)