Open DionSun opened 5 years ago
你好,我遇到问题,请求帮助~ 感谢 需求:有d2-crud table,需要要根据后端返回得数据来更新columns和data,第一次查询更新能得到正确得记过 问题:当第二返回数据得columns 和前一次不一样时,d2-crud 显示得数据就不正确了。 版本: "@d2-projects/d2-crud": "^2.1.1",
样例数据如下, res2 比res1多一个 column "key": "成缆_201934",
data () { return { table: [], columns: [], cur : 1, res1 :{ "rows": [ { "product": "普通", "成缆_201934": 1, "成缆_201935": 0, "成缆_201936": 1, }, ], "tablecolumns": [ { "key": "product", "title": "产品" }, { "children": [ { "key": "成缆_201935", "title": "201935" }, { "key": "成缆_201936", "title": "201936" } ], "title": "成缆" } ] }, res2 : { "rows": [ { "product": "普通", "成缆_201934": 1, "成缆_201935": 0, "成缆_201936": 1, }, ], "tablecolumns": [ { "key": "product", "title": "产品" }, { "children": [ { "key": "成缆_201934", "title": "201934" }, { "key": "成缆_201935", "title": "201935" }, { "key": "成缆_201936", "title": "201936" } ], "title": "成缆" } ] }, } },
更新table得代码
if (this.cur == 1){ this.columns = this.res1.tablecolumns this.table = this.res1.rows this.cur =2 } else{ this.columns = this.res2.tablecolumns this.table = this.res2.rows this.cur =1 } }
第二次数据更新后,
第一行数据显示 :普通 | 0 | 1 | 1 正确得显示 应该为 :普通 | 1 | 0 | 1
把 d2-crud src 复制到项目调试时发现,编译时有错误,'' cannot be keyed. Place the key on real elements instead
你好,我遇到问题,请求帮助~ 感谢 需求:有d2-crud table,需要要根据后端返回得数据来更新columns和data,第一次查询更新能得到正确得记过 问题:当第二返回数据得columns 和前一次不一样时,d2-crud 显示得数据就不正确了。 版本: "@d2-projects/d2-crud": "^2.1.1",
data () { return { table: [], columns: [], cur : 1, res1 :{ "rows": [ { "product": "普通", "成缆_201934": 1, "成缆_201935": 0, "成缆_201936": 1, }, ], "tablecolumns": [ { "key": "product", "title": "产品" }, { "children": [ { "key": "成缆_201935", "title": "201935" }, { "key": "成缆_201936", "title": "201936" } ], "title": "成缆" } ] }, res2 : { "rows": [ { "product": "普通", "成缆_201934": 1, "成缆_201935": 0, "成缆_201936": 1, }, ], "tablecolumns": [ { "key": "product", "title": "产品" }, { "children": [ { "key": "成缆_201934", "title": "201934" }, { "key": "成缆_201935", "title": "201935" }, { "key": "成缆_201936", "title": "201936" } ], "title": "成缆" } ] }, } },
if (this.cur == 1){ this.columns = this.res1.tablecolumns this.table = this.res1.rows this.cur =2 } else{ this.columns = this.res2.tablecolumns this.table = this.res2.rows this.cur =1 } }
第一行数据显示 :普通 | 0 | 1 | 1 正确得显示 应该为 :普通 | 1 | 0 | 1