关于element-ui popover组件通过数据渲染出多个popover时点击取消时 popover的显示与隐藏问题

引用作者https://blog.csdn.net/Gunahao/article/details/79491879

      </el-table-column>**`el-table-column fixed="right" label="操作" width="150px">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="editorRow(scope.$index, tableData)"
            type="primary"
            size="small"
          >
            编辑
          </el-button>
                    <el-popconfirm
                        placement="bottom"
                        width="160"
                        trigger="click"
                        v-model="scope.row.visible"
                        title="确认删除吗?"
                    >
                      <div style="text-align: right; margin: 0">
                        <el-button size="mini" type="text" @click="scope.row.visible=false">取消</el-button>
                        <el-button type="primary" size="mini" @click="
                        scope.row.visible=false">确定</el-button>
                      </div>
                      <el-button slot="reference" size="small" @click="scope.row.visible=true">删除</el-button>
                    </el-popconfirm>
        </template>
      </el-table-column>`
  **思路:当数据数据是自定义时,我们可以在每个条数据对象中添加一条属性visible: false**
tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
          visible: false
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
          visible: false
        }]

给操作按钮添加 slot= "reference"s属性控制popover的现实,且将v-model中的值设为tableData中的visible值。点击取消或确定也要讲对应数据中的visible设为false并处理相关逻辑。若数据为后台返回。可在使用数据时遍历一遍数据,并给每条数据添加一个标识为false即可,到此问题解决了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值