antd vue 这里tree控件默认选中为什么不行?
简略了一下代码
感觉不错啊,不应该选中id 527,530 的数据吗,谢谢各位啦
<a-tree :replaceFields="replaceFields"
v-model="checkedKeys"
default-checked-keys="[527,530]"
:tree-data="permission"
/>
// 节点替换
replaceFields: {
children: 'children',
title: 'name',
key: 'id'
},
// 数据
[{
"id": 527,
"name": "权限测试1",
"pid": 0,
"pids": "0,",
"description": "permission1",
"children": [{
"id": 530,
"name": "权限测试1-1",
"pid": 527,
"pids": "0,527,",
"description": "permission1-1",
"children": [{
"id": 531,
"name": "权限测试1-1-1",
"pid": 530,
"pids": "0,527,530,",
"description": "permission1-1-1",
"children": null
},
{
"id": 533,
"name": "权限测试1-1-2",
"pid": 530,
"pids": "0,527,530,",
"description": "permission1-1-2",
"children": null
}
]
},
{
"id": 532,
"name": "权限测试1-2",
"pid": 527,
"pids": "0,527,",
"description": "permission1-2",
"children": null
}
]
},
{
"id": 528,
"name": "权限测试2",
"pid": 0,
"pids": "0,",
"description": "permission2",
"children": null
}
]
回答:
尝试 toString()
回答:
default-checked-keys 前面需要加冒号,说明后面的是一个变量或者表达式
回答:
其实两天也是遇到这种问题,还没来得详细看到底是为什么不行,不过在调试的时候发现:
使用v-model 绑定时 直接把 选中的值 给checkedKeys
<a-tree :replace-fields="replaceFields"
v-model="checkedKeys"
:tree-data="permission"
/>
data中checkedKeys:[532]
不用v-model时 给defaultCheckedKeys绑定值 是可以的
<a-tree :replace-fields="replaceFields"
:default-checked-keys="[532]"
:tree-data="permission"
/>
官方例子中也没有发现两个同时使用的情况
以上是 antd vue 这里tree控件默认选中为什么不行? 的全部内容, 来源链接: utcz.com/p/935434.html