Element: bug 下拉框,模糊搜索有问题

Created on 11 Jan 2017  ·  4Comments  ·  Source: ElemeFE/element

demo:http://jsrun.net/TzpKp/edit
现象:无法输入B/C/1过滤,自动清除了输入的值

Most helpful comment

el-option 需要加 key

<el-option v-for="item in myoptions" :key="item.id" :label="item.name" :value="item.id">

参考 #2170

All 4 comments

把你的v-model="V1"改成小写的v1就行了

改了也不行啊 除了A和匹配不到的值可以输入,匹配到的都自动清除了

@AaronChen2012 不用computed,这样写呢?

new Vue({
  el:'#app',
  data:{
    v1:'',
    options:[
      {id:'1',code:'1',name:'A'},
      {id:'2',code:'2',name:'B'},
      {id:'11',code:'11',name:'C'}],
    myoptions:[
      {id:'1',code:'1',name:'A'},
      {id:'2',code:'2',name:'B'},
      {id:'11',code:'11',name:'C'}]
  },
  methods: {
    filtermethod(val){
      if (val){
        this.myoptions = this.options.filter(obj=>obj.name.includes(val)||obj.code.includes(val))
      }else{
        this.myoptions = this.options
      }
    }
  }
});

el-option 需要加 key

<el-option v-for="item in myoptions" :key="item.id" :label="item.name" :value="item.id">

参考 #2170

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yubo111 picture yubo111  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

chenzhe-pro picture chenzhe-pro  ·  3Comments

makunsusu picture makunsusu  ·  3Comments

yuchonghua picture yuchonghua  ·  3Comments