mardi 2 juillet 2019

How to fix this problem "TypeError: this.source2.filter is not a function"

Hello i'm use php laravel to get data from database and redis to show it with vuejs and when i'm try to use the filtre i get this problem : "TypeError: this.source2.filter is not a function

when i'm use filteredList in source of database it's working fine and the filtre also .. and when i'm try use it with source2 i get the error and no data show it

  props: {
      title:  {
        type:    String,
      },
      source: {
        type:     [Object, Array],
      },
      source2: {
        type:     [Object, Array],
      },
       id:     {
        type: String,
      }
    },
     data() {
      return {
        search: '',
      }
      computed: {
            filteredList() {
             return this.source2.filter(data => {
              return data.nIdent.toLowerCase().includes(this.search.toLowerCase())
            })
          }
  }
    
<div class="panel-body" style="padding:0">
              <select ref="available" class="form-control multiselect" id="prodn" size="20" multiple>
                <template v-for="data in source2">
                     <option v-if="id == 'PS'"  :title="data.iDesc" class="select-opt" :value="data.nIdent"> -  - </option>
                </template>
              </select>
            </div>
<div class="panel-body" style="padding:0">
              <select ref="selected" class="form-control" id="prodo" size="20" multiple>
                <template v-for="data in source">
                    <option v-if="id == 'PS'" :title="data.description_service" class="select-opt" :value="data.num_service"> -  - </option>
                </template>
              </select>
            </div>
          </div>

i have not problem to showing data i have in filter of data i need to make the filter work with both sources



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire