Invalid prop: type check failed for prop "items". Expected Array, got String
13,833
Solution 1
I got the answer
Here i declared 'province' as string and 'listProvince' as array
Thanks
Solution 2
To complete the answer with an example... example from Vue site:
props: {
title: String,
likes: Number,
isPublished: Boolean,
commentIds: Array,
author: Object,
callback: Function,
contactsPromise: Promise // or any other constructor
}
for more info: https://vuejs.org/v2/guide/components-props.html
Related videos on Youtube
Author by
ramees
Updated on June 04, 2022Comments
-
ramees almost 2 years
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
-
Roberto Zvjerković over 5 yearsI mean, the error is pretty sefl-explanatory. You're tring to bind a string (province) to something that expects an array (v-bind:items).
-
ramees over 5 yearswhere do i declare items as array here?
-
Roberto Zvjerković over 5 yearsYou didn't, which is the problem.
-
ramees over 5 yearsi am new to vue js so where do i declare it? thanks
-
Roberto Zvjerković over 5 years
province: "",
It should beprovince: ["something", "something"],
-
ramees over 5 yearsis it in the data section?
-
Roberto Zvjerković over 5 yearsProbably, I have never used Vue. Whereever you declare the property province, which is bound to
<select v-bind:items
, you should declare it as[]
-
ramees over 5 yearsi want string in province and i am declared it as string in the data section but still getting error
-
Roberto Zvjerković over 5 yearsYou 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"]
-