解决使用行内el-input修改值时视图没有更新得问题

<template>
  <div class="ele-body">
      <el-table
        :data="list"
        :span-method="objectSpanMethod"
        border
        style="width: 100%; margin-top: 20px"
      >
        <el-table-column label="小类/价格" align="center">
          <template slot-scope="scope">
            <div
              v-for="item in scope.row.sub"
              :key="item.id"
              style="display:flex;align-items: center;"
            >
              {{ item.name }}
     //用el-input就不能做响应式,所以用了input然后再把el-input的css样式copy了
              <input
                class="input__inner"
                style="width: 150px;margin:5px auto"
                placeholder="请输入价格"
                v-model="item.price"
              />
            </div>
          </template>
        </el-table-column>
      </el-table>
  </div>
</template>

<script>
 
   this.$set(this.list, index, item);//填自己的值
   //对应:要更改的数据源(可以是对象或者数组) 要更改的具体数据  重新赋的值
</script>
<style scoped>

.input__inner {
  -webkit-appearance: none;
  background-color: var(--input-background-color);
  background-image: none;
  border-radius: 4px;
  border: 1px solid var(--border-color-base);
  box-sizing: border-box;
  color: var(--color-text-regular);
  display: inline-block;
  font-size: inherit;
  height: 40px;
  line-height: 40px;
  outline: none;
  padding: 0 15px;
  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  width: 100%;
}
</style>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值