admin管理员组文章数量:1310431
I have a dropdown in vue js.
<v-flex> <v-select label="Select Province" v-bind:items="listProvince" outline v-model="province" persistent-hint @change="loadCity()"></v-select>
</v-flex>
and in the 'listProvince' I am getting data and displayed in the dropdown but in console I am getting this error Invalid prop: type check failed for prop "items". Expected Array, got String.
This is the vue js code:
export default {
props: ["updateView","newBooking"],
data() {
return {
selected: [0],
shipper: "",
address: "",
barangay: "",
city: "",
province: "",
phone: "",
listProvince:"",
selectedCity:"",
bookingObject: {},
isNewBk: false,
};
}
}
Please help me thanks in advance
I have a dropdown in vue js.
<v-flex> <v-select label="Select Province" v-bind:items="listProvince" outline v-model="province" persistent-hint @change="loadCity()"></v-select>
</v-flex>
and in the 'listProvince' I am getting data and displayed in the dropdown but in console I am getting this error Invalid prop: type check failed for prop "items". Expected Array, got String.
This is the vue js code:
export default {
props: ["updateView","newBooking"],
data() {
return {
selected: [0],
shipper: "",
address: "",
barangay: "",
city: "",
province: "",
phone: "",
listProvince:"",
selectedCity:"",
bookingObject: {},
isNewBk: false,
};
}
}
Please help me thanks in advance
Share Improve this question edited Nov 26, 2018 at 4:36 ramees asked Nov 23, 2018 at 9:53 rameesramees 511 gold badge1 silver badge8 bronze badges 9- 3 I mean, the error is pretty sefl-explanatory. You're tring to bind a string (province) to something that expects an array (v-bind:items). – Roberto Zvjerković Commented Nov 23, 2018 at 9:59
- where do i declare items as array here? – ramees Commented Nov 23, 2018 at 10:01
- You didn't, which is the problem. – Roberto Zvjerković Commented Nov 23, 2018 at 10:02
-
1
province: "",
It should beprovince: ["something", "something"],
– Roberto Zvjerković Commented Nov 23, 2018 at 10:03 -
1
You SHOULDN'T declare it as a string.
selectedProvince
should be a string,province
should be renamed toprovinces
and it should be an array:["province1", "province2"]
– Roberto Zvjerković Commented Nov 23, 2018 at 10:11
3 Answers
Reset to default 1To plete the answer with an example... example from Vue site:
props: {
title: String,
likes: Number,
isPublished: Boolean,
mentIds: Array,
author: Object,
callback: Function,
contactsPromise: Promise // or any other constructor
}
for more info: https://v2.vuejs/v2/guide/ponents-props.html
I got the answer
Here i declared province
as string and listProvince
as array
Thanks
Incase someone still feel confuse on ramees answer like I did, here is the real example of the final setting
data() {
return {
province: "",
listProvince:['option 1','option 2'],
};
This declare listProvince as array (the dropdown select options) while province as string (the selected dropdown value).
Hope this provide additional help to someone who needs it!
本文标签:
版权声明:本文标题:javascript - Invalid prop: type check failed for prop "items". Expected Array, got String - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741833925a2400100.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论