我遇到了一个问题,我无法让object
expression正确显示我想要的内容。
当前行为: Vue-Multiselect
这是我的代码:
<multiselect
v-model="displayCategories"
:selected="displayCategories"
:options="optionsForSubCat"
:searchable="false"
:allow-empty="true"
deselect-label="Can't remove this value"
label="subCategories"
track-by="subCategories"
>
</multiselect>
这是我的json对象,用于显示子类别的类型:
"displayCategories": {
"categoryId": "3080854a-13d9-4e38-ab96-358aa6405a2c",
"categoryName": "Furniture",
"subCategories": [
{
"subCategoryName": "Sofa",
"subCategoryId": "21eb061d-9c67-4c55-ac48-e33e684a307c",
"createdAt": "2017-07-24T13:07:18.000Z",
"updatedAt": "2017-07-24T13:08:28.000Z",
"fk_categoryId": "3080854a-13d9-4e38-ab96-358aa6405a2c"
},
{
"subCategoryName": "Bed",
"subCategoryId": "2af11eee-5fce-4d97-b483-00a02de123ca",
"createdAt": "2017-07-24T13:06:04.000Z",
"updatedAt": "2017-07-24T13:08:28.000Z",
"fk_categoryId": "3080854a-13d9-4e38-ab96-358aa6405a2c"
}
]
}
即使我将标签和追踪更改为“subCategoryName”,它也根本不会显示下拉列表。
预期的行为将是Multiselect将在下拉列表中显示“Sofa”,“Bed”。
我如何实现预期的行为?
感谢您的帮助!