._a-table 点击行在当前行下面 弹出a-p">
当前位置:   article > 正文

Vue+Element 解决Popover弹出框在table列表中的问题(弹出多个弹框 || 关闭弹框失败)_a-table 点击行在当前行下面 弹出a-popover组件

a-table 点击行在当前行下面 弹出a-popover组件

在使用Vue+ElementUI做项目的过程中,在table列表中使用Popover弹出框出现的BUG让我头都大了,官网没有给出具体的解决方案,于是在百度这片肥沃的土壤里寻找答案。试了好多种方案,最终在下面博客的评论里找到了解决办法。

参考博客

下面贴出我的代码

局部代码:

  1. <!-- 删除用户弹窗 -->
  2. <el-popover placement="top" width="160" :ref="`deluser-popover-${scope.$index}`">
  3. <p>确定删除该用户吗?</p>
  4. <div style="text-align: right; margin: 0">
  5. <el-button size="mini" type="text" @click="scope._self.$refs[`deluser-popover-${scope.$index}`].doClose()">取消</el-button>
  6. <el-button type="primary" size="mini" @click="delUser(scope.row, scope.$index, userTableData), scope._self.$refs[`deluser-popover-${scope.$index}`].doClose()">确定</el-button>
  7. </div>
  8. <el-button type="text" size="small" slot="reference">删除</el-button>
  9. </el-popover>

table代码 :

  1. <!-- 用户列表 -->
  2. <el-table :data="userTableData" style="width: 100%; margin-top: 20px" size="small">
  3. <el-table-column prop="username" label="登录名" width="140"></el-table-column>
  4. <el-table-column prop="nickname" label="姓名" width="120"></el-table-column>
  5. <el-table-column label="身份" width="120">
  6. <template slot-scope="scope">
  7. <template v-if="scope.row.is_auditor">审计管理员</template>
  8. <template v-else-if="scope.row.is_supper">超级管理员</template>
  9. <template v-else>普通用户</template>
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="role_name" label="角色" width="120"></el-table-column>
  13. <el-table-column prop="is_active" label="状态" width="120" :filters="[{ text: '启用', value: '启用' }, { text: '禁用', value: '禁用' }]" :filter-method="filterTag">
  14. <template slot-scope="scope">
  15. <el-tag :type="scope.row.is_active ? 'success' : 'primary'" close-transition>{{ scope.row.is_active ? "启用" : "禁用" }}</el-tag>
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="last_login" label="最近登录"></el-table-column>
  19. <el-table-column prop="operation" label="操作" width="200">
  20. <template slot-scope="scope">
  21. <el-popover placement="top" width="160" :ref="`disuser-popover-${scope.$index}`">
  22. <p>确定禁用该用户吗?</p>
  23. <div style="text-align: right; margin: 0">
  24. <el-button size="mini" type="text" @click="scope._self.$refs[`disuser-popover-${scope.$index}`].doClose()">取消</el-button>
  25. <el-button type="primary" size="mini" @click="isEnabledUser(scope.row.id, scope.row.is_active), scope._self.$refs[`disuser-popover-${scope.$index}`].doClose()">确定</el-button>
  26. </div>
  27. <el-button type="text" size="small" slot="reference" style="margin-right: 6px">{{ scope.row.is_active ? "禁用" : "启用" }}</el-button>
  28. </el-popover>
  29. <el-button @click="editUserForm = true" type="text" size="small" style="margin-right: 6px">编辑</el-button>
  30. <el-popover placement="top" width="160" :ref="`resetpw-popover-${scope.$index}`">
  31. <p>重置密码为000000?</p>
  32. <div style="text-align: right; margin: 0">
  33. <el-button size="mini" type="text" @click="scope._self.$refs[`resetpw-popover-${scope.$index}`].doClose()">取消</el-button>
  34. <el-button type="primary" size="mini" @click="resetPW(scope.row), scope._self.$refs[`resetpw-popover-${scope.$index}`].doClose()">确定</el-button>
  35. </div>
  36. <el-button type="text" size="small" slot="reference" style="margin-right: 6px">重置密码</el-button>
  37. </el-popover>
  38. <!-- 删除用户弹窗 -->
  39. <el-popover placement="top" width="160" :ref="`deluser-popover-${scope.$index}`">
  40. <p>确定删除该用户吗?</p>
  41. <div style="text-align: right; margin: 0">
  42. <el-button size="mini" type="text" @click="scope._self.$refs[`deluser-popover-${scope.$index}`].doClose()">取消</el-button>
  43. <el-button type="primary" size="mini" @click="delUser(scope.row, scope.$index, userTableData), scope._self.$refs[`deluser-popover-${scope.$index}`].doClose()">确定</el-button>
  44. </div>
  45. <el-button type="text" size="small" slot="reference">删除</el-button>
  46. </el-popover>
  47. </template>
  48. </el-table-column>
  49. </el-table>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/104879
推荐阅读
相关标签
  

闽ICP备14008679号