ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.12k stars 14.64k forks source link

vue2+vuex+strict多选时的bug #2910

Closed wilsonIs closed 7 years ago

wilsonIs commented 7 years ago

环境:vue2+vuex2

设置:strict:true

问题:对表单控件设置为多选及严格模式下,devtool报错,

[vuex] Do not mutate vuex store state outside mutation handlers.

而如果是在单选或者是非严格模式下,都没有该错误。

代码:

<el-select :value="thisRecruitDepts" multiple filterable placeholder="请选择"    @change="handleSearchSubmit">
       <el-option v-for="item in selectOpt.recruitDepts"  :label="item.Name"  :value="item.Id">
      </el-option>
</el-select>

computed:{
    thisRecruitDepts:{
          get(){
                return this.searchCriteria.param.recruitDepts;
           },
          set(val){
              this.changeSearchCriteria({
                   recruitDepts:val
               })
           }
     }
}

探索:测试显示,在select点击的时候,没有执行set方法,求解?

Leopoldthecoder commented 7 years ago

参考一下 https://github.com/ElemeFE/element/issues/1632#issuecomment-265739660

wilsonIs commented 7 years ago

@Leopoldthecoder 依然报错如下,在this.value.push(option.value)的时候,报错如图1,没有触发@input事件,也没有触发绑定的value的setter,这种赋值方法是否不符合vue的规范?

Leopoldthecoder commented 7 years ago

贴一下代码