no message
Former-commit-id: 66754231f5c27d4bb4d5fbd59e26ec7bde67fe68 Former-commit-id: d08ce15bfa566c78d32d73c60f2c2899faad6771 Former-commit-id: ea51e05553a750cbc8bb811dec10608de588626f
This commit is contained in:
@@ -51,10 +51,19 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 请求数据
|
// 请求数据
|
||||||
async getData () {
|
async getData () {
|
||||||
this.table.data = await this.dataMaker()
|
this.table.data = this.dataFilter(await this.dataMaker())
|
||||||
},
|
},
|
||||||
// 生成数据 模拟 Ajax
|
// 过滤数据部分 模拟过滤掉 star 字段
|
||||||
// 没有必要写在全局 mock 设置中,就在这里这样写了,这样删文件的时候也好处理
|
dataFilter (val) {
|
||||||
|
const rowFilter = ({
|
||||||
|
id = '',
|
||||||
|
name = '',
|
||||||
|
address1 = '',
|
||||||
|
address2 = ''
|
||||||
|
}) => ({id, name, address1, address2})
|
||||||
|
return val.map(e => rowFilter(val))
|
||||||
|
},
|
||||||
|
// 模拟返回数据。没有必要写在全局 mock 设置中,就在这里这样写了,这样删文件的时候也好处理
|
||||||
dataMaker () {
|
dataMaker () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve(Mock.mock({
|
resolve(Mock.mock({
|
||||||
@@ -62,7 +71,8 @@ export default {
|
|||||||
'id|+1': 1,
|
'id|+1': 1,
|
||||||
'name': '@CNAME',
|
'name': '@CNAME',
|
||||||
'address1': '@CITY',
|
'address1': '@CITY',
|
||||||
'address2': '@CITY'
|
'address2': '@CITY',
|
||||||
|
'star|1-5': '★'
|
||||||
}]
|
}]
|
||||||
}).list)
|
}).list)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user