[Vuejs]-Cannot use 'in' operator to search for 'selectedItem' in null

0๐Ÿ‘

โœ…

I have solved it by adding value-key attribute to my select component as follows:

 <el-select  v-model="selectedItem" value-key="selectedItem.value" filterable class="sm-column-width"
   remote placeholder="Please enter a keyword" :remote-method="querySearchItems"
   :loading="loading" @change="setItem">
           <el-option v-for="item in listItem" :key="item.value" :label="item.label" :value="item.value">
           </el-option>
 </el-select>

Also I have changed the declaration of my selectedItem (under data) as:

...
selectedItem: {label:'' , id: ''}
...

And when I queried, I assigned the value as follows:

  this.$http.get('localhost:8080/api/'+'items/' + id)
                  .then((response) => {
                  this.selectedItem = { label: response.body.itemName, value: response.body.id };
              });
๐Ÿ‘คRed fx

Leave a comment