el-table 中嵌入el-input 输入框无法输入问题(已解决)

在使用elment ui中的el-table 中嵌入el-input,会出现 input 无法输入的情况

最后找到了问题的根源,是有时候获取到了数据,但是视图并没有更新

修改前代码

  <el-table-column :sortable="true" :label="$t('dispatchRe.qty')">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" style="width: 89px" />
            </template>
          </el-table-column>

修改后

  <el-table-column :sortable="true" :label="$t('dispatchRe.qty')">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" @input="changeValue" style="width: 89px" />
            </template>
          </el-table-column>

解决办法使用@input事件:

在输入框值改变的时候,调用this.$forceUpdate()强制刷新

猜你喜欢

转载自blog.csdn.net/Maxueyingying/article/details/131824213