如何将v-model与object结合使用



当我尝试将对象添加到数据中并将其绑定为v-modal时,我会得到以下错误

Map: Expected mapDiv of type HTMLElement but was passed undefined.

脚本:

data() {
return {
test: { propertyType: "Residential" },
};
},

模板:

<Select
v-model="test.propertyType"
label="Property type"
:options="options.propertyTypes"
:validation="$v.propertyType"
:allow-empty="false"
/>

选项助手:

propertyTypes: ["Residential", "Commercial"],

浏览器控制台:

Property or method "propertyType" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
[Vue warn]: Invalid prop: type check failed for prop "options". Expected Array, got Undefined 
found in
---> <VueMultiselect>
<CustomSelect> at components/ui/Select.vue
<Pages/applications/create.vue> at pages/applications/create.vue
<Nuxt>
<Layouts/default.vue> at layouts/default.vue
<Root>
found in
---> <Pages/applications/create.vue> at pages/applications/create.vue
<Nuxt>
<Layouts/default.vue> at layouts/default.vue
<Root>

数据状态中未定义的options.propertyTypes,只需定义即可!

data() {
return {
test: { propertyType: "Residential" },
options: {
propertyTypes: ["Residential", "Commercial"]
}
};

},

最新更新