Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d2-crud 表格更新 columns后 数据不能正常显示。 #67

Open
DionSun opened this issue Sep 9, 2019 · 1 comment
Open

d2-crud 表格更新 columns后 数据不能正常显示。 #67

DionSun opened this issue Sep 9, 2019 · 1 comment

Comments

@DionSun
Copy link

DionSun commented Sep 9, 2019

你好,我遇到问题,请求帮助~ 感谢
需求:有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

@DionSun
Copy link
Author

DionSun commented Sep 12, 2019

把 d2-crud src 复制到项目调试时发现,编译时有错误,'' cannot be keyed. Place the key on real elements instead

template 改成span 后 ,发现数据就能正常显示了。

我是vue的初学者,不明白其中原理。但是表面上看上去可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant