使用element的組件實現根據輸入的內容動態請求數據形成下拉列表(el-select)

<el-select v-model="listOption.brand" filterable placeholder="品牌名稱"  :filter-method="brandKeyChange">
              <el-option
                v-for="item in BrandListData"
                :key="item.id"
                :label="item.brand"
                :value="item.brand">
              </el-option>
            </el-select>

filter-method在輸入時觸發

brandKeyChange:function(inputKey){
        //inputKey爲當前輸入的數據
        this.gob.getBrandListData(this,inputKey,(list)=>{//根據輸入的數據請求,得到的結果作爲渲染的下拉數據
          this.BrandListData=list;
      })
  },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章