VUE的input框赋值后无法进行编辑

问题情况 : data中有定义对应字段,input框也进行绑定对了v-model 但进行赋值后,input输入框无法进行操作
原因: 空input框进行赋值后,不存在setter和getter方法,导致无法实现双向绑定

解决办法

<template>
   <el-select v-model='this.form.value' @change='selectHandle'>
      <el-option 
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
   </el-select>
   <el-input v-model='this.form.inp'>
</template>
<script>
   export default{
     return{
       data(){
         form{
              value:'',inp:''
         },
         options:[]
       },
       methods:{
           selectHandle(val){
             let reassign = val + ':';
             this.$set(this.form,'inp',val)
           } 
       }
     }
   }
</script>
<style><style>

猜你喜欢

转载自blog.csdn.net/qq_42753983/article/details/130271658