From 54954f75f96a9dea3e42d43317c5f416c93f2d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9D=A8?= <1711467488@qq.com> Date: Fri, 23 Mar 2018 14:26:17 +0800 Subject: [PATCH] no message Former-commit-id: 66754231f5c27d4bb4d5fbd59e26ec7bde67fe68 Former-commit-id: d08ce15bfa566c78d32d73c60f2c2899faad6771 Former-commit-id: ea51e05553a750cbc8bb811dec10608de588626f --- .../demo/business/table/keyboard/inedx.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/demo/business/table/keyboard/inedx.vue b/src/pages/demo/business/table/keyboard/inedx.vue index 23d1fdfa..45707f39 100644 --- a/src/pages/demo/business/table/keyboard/inedx.vue +++ b/src/pages/demo/business/table/keyboard/inedx.vue @@ -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) })