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

Share:
13,833

Related videos on Youtube

ramees
Author by

ramees

Updated on June 04, 2022

Comments

  • ramees
    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ć
      Roberto Zvjerković over 5 years
      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).
    • ramees
      ramees over 5 years
      where do i declare items as array here?
    • Roberto Zvjerković
      Roberto Zvjerković over 5 years
      You didn't, which is the problem.
    • ramees
      ramees over 5 years
      i am new to vue js so where do i declare it? thanks
    • Roberto Zvjerković
      Roberto Zvjerković over 5 years
      province: "", It should be province: ["something", "something"],
    • ramees
      ramees over 5 years
      is it in the data section?
    • Roberto Zvjerković
      Roberto Zvjerković over 5 years
      Probably, 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
      ramees over 5 years
      i want string in province and i am declared it as string in the data section but still getting error
    • Roberto Zvjerković
      Roberto Zvjerković over 5 years
      You SHOULDN'T declare it as a string. selectedProvince should be a string, province should be renamed to provinces and it should be an array: ["province1", "province2"]