vue2.0 el-table 点击小图标 怎么修改行内某个值

需求分析:Vue 的双向数据绑定,使得修改数据后,视图就会跟着发生更新,比如对数组进行增加元素、切割等操作。然而直接通过下标修改数组内容后,视图却不发生变化,因此,我们要想通过index下标来改变数组来达到目的是行不通的。这时我们可以使用Vue.set(对象,属性,值)或 this.$set(对象,属性,值)来改变数组

代码如下:

 <el-table-column align="center" label="访问分数" min-width="300px">

                  <template slot-scope="scope">

                    <div v-if="scope.row.flag">

                      <el-col :span="14" style="padding-left:0px;padding-right:0px">

                        <el-input-number

                          v-model="scope.row.api_importance_value"

                          controls-position="right"

                          :min="-1"

                          :max="100"

                          @change="handleChange1"

                        />

                      </el-col>

                      <el-col :span="6" style="padding-left:0px;padding-right:0px;margin-top:10px;margin-left:20px">

                        <span style="color:blue ;cursor:pointer;margin-top:10px;" @click="save(scope.$index,scope.row)"><i class="el-icon-circle-check" /></span>

                        <span style="color:blue ;cursor:pointer;margin-top:10px;margin-left:10px" @click="remove(scope.$index,scope.row)"> <i class="el-icon-circle-close" /></span>

                      </el-col>

                    </div>

                    <span v-else class="spanan">{{ scope.row.api_importance_value }}<i class="el-icon-edit-outline" style="margin-left:20px;color:blue ;cursor:pointer;" @click.prevent="editShow(scope.$index,scope.row)" /></span>

                  </template>

                </el-table-column>

方法: this.$set(对象,属性,值)

 //打开

  editorShow(index, rows) {

      this.$set(this.tableData[index], 'flag', true)

    },

  // 关闭

    async  remove(index, rows) {

      this.$set(this.tableData[index], 'flag', false)

    },

   //保存

    async  saveeditor(index, rows) {

      this.$set(this.tableData[index], 'flag', false)

    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值