no message

Former-commit-id: 66754231f5c27d4bb4d5fbd59e26ec7bde67fe68
Former-commit-id: d08ce15bfa566c78d32d73c60f2c2899faad6771
Former-commit-id: ea51e05553a750cbc8bb811dec10608de588626f
This commit is contained in:
李杨
2018-03-23 14:26:17 +08:00
parent f6e287b9b0
commit 54954f75f9

View File

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