element table 改变数据列表不更新

  1. 方法1

给Table一个实时更新的key:这样操作之后,会认为不是同一张表格,会重新渲染一遍。

this.renderTable = new Date().valueOf()
this.skus[index].disabled = false
            <el-table :data="skus" max-height="1000" v-show="!showSku" :key="renderTable">
                <el-table-column
                  v-for="(attr,index) in form.h2ProductSkuAttributeList"
                  :key="attr.name"
                  align="center"
                  width="100"
                  :label="attr.name"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <span>{{optionMap[(scope.row.skuAttribute[attr.id])]}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="商品名称" align="center" prop="name" width="160">
                  <template slot-scope="scope">
                    <el-input
                      placeholder="商品名称"
                      :disabled="scope.row.disabled"
                      v-model="scope.row.name"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="图片" align="center" prop="image" width="150">
                  <div class="sku-attr" slot-scope="scope">
                    <oss-image-preview
                      v-if="disabled"
                      :src="scope.row.image"
                      :width="80"
                      :height="80"
                    />
                    <image-upload
                      v-else
                      :is-show-tip="false"
                      :limit="1"
                      :disabled="scope.row.disabled"
                      v-model="scope.row.image"
                      :model="$yun.FileEnum.PRODUCT_GOODS_IMG"
                    />
                    <el-button
                      type="text"
                      v-if="!scope.row.disabled"
                      @click="uploadImage(scope.row)"
                    >上传图片</el-button>
                  </div>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align="center"
                  class-name="small-padding fixed-width"
                  width="160"
                >
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      v-if="scope.row.disabled"
                      @click="updateDisable(scope.$index)"
                    >修改</el-button>
                    <el-button
                      type="text"
                      @click="updataSkuCurrent(scope.row,scope.$index)"
                      v-else
                    >确定</el-button>
                  </template>
                </el-table-column>
              </el-table>
  1. 方法二
    使用 this.$set(this.data,index,row),比较消耗性能
this.$set(this.skus[index], 'disabled', false)
  • 12
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值