vue.js - 具有深层嵌套数据的 Vue 选择
问题描述
我正在尝试根据官方文档上的说明进行 v-select,但我的数据比文档中显示的更嵌套,我无法在我的 v-select 中显示我的数据的llcName,我被困住了.
这是我的 html div 和 Vue 实例,数据如下
<div id="vs">
<h1>Vue Select</h1>
<v-select multiple :options="options" :reduce="node=> node.llcName" label='llcName' v-model='selected' />
<pre>[[$data]]</pre>
</div>
<script>
Vue.component('v-select', VueSelect.VueSelect)
new Vue({
el: '#vs',
delimiters: ["[[", "]]"],
data: {
options: [
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA1",
"llcName": "new",
"suppPayment": {
"edges": [0]
}
}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA2",
"llcName": "new2",
"suppPayment": {
"edges": [1]
}
}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA3",
"llcName": "rteer",
"suppPayment": {
"edges": [2]
}
}
}
],
selected:"",
}
})
</script>
解决方案
我认为你应该使用getOptionLabel而不是你的财产label
有错误。reduce
<v-select
multiple
v-model='selected'
:options='options'
:get-option-label='option => option.node.llcName'
:reduce='option => option.node.llcName'/>
推荐阅读
- java - java - 在使用ObjectInputStream反序列化Java时如何检查EOF
- java - 创建 bmi 计算器时出错
- javascript - 标签颜色与背景颜色相同 - ChartJS
- r - 如何将 R 的 S3 类与参数一起使用?
- visual-studio-code - 如何限制我的 VS Code 扩展的 VS Code 引擎最低版本?
- assembly - 'imul' 的操作数大小不匹配
- scala - 如何从响应中获取价值?
- python - 无法修复“ValueError:未正确调用 DataFrame 构造函数!”
- c++ - 尽管已安装,但在 MinGW 中找不到 gtkmm
- python - 如何删除矩阵中的一些条目。我正在从 matlab 转换为 python