Element-UI中el-table内嵌el-popover,在表格翻页后el-popover无法显示问题解决
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
由于开发需求,需要在el-table某一列增加popover弹窗,当用户点击按钮时,通过popover组件展示详细信息。参考Element-ui官网文档案例,得出代码如下
<el-table-column prop="sip,sip_location" label="源IP" width="150">
<template slot-scope="scope">
<div>
{{ scope.row.sip }}
<el-popover
placement="right"
width="500px"
:visible="IPDetailsPop"
popper-class="IPDetailsPopover"
>
<IPDetails ref="ipdetails" :info="info"/>
<el-button
type="text"
icon="el-icon-search"
slot="reference"
@click="toggleIPDetailsDialog(scope.$index,'sip')"
>
</el-button>
</el-popover>
</div>
<div v-for="item in scope.row.sip_location" :key="item">
<div style="margin-bottom:2px">
<el-tag effect="dark" color="#199fc7" size="mini" span="2" style="width:100%">{{
item
}}</el-tag>
</div>
</div>
</template>
</el-table-column>
具体实现细节无需关注,经过测试后表格第一页的popover组件能够正常显示,但是当翻到第二页时,点击详情按钮,函数能够被正常执行,数据也按照指定格式解析,但是popover组件无法显示。此时返回到第一页后,第一页的popover组件也无法显示了。
参考文章(https://juejin.cn/post/7200571354927939645#comment)中对组件复用问题的描述与解释,在el-popover添加v-if判断条件成功将问题解决,即当没有详细数据要展示的时候,不渲染popover组件。
<el-table-column prop="sip,sip_location" label="源IP" width="150">
<template slot-scope="scope">
<div>
{{ scope.row.sip }}
<el-popover
placement="right"
width="500px"
:visible="IPDetailsPop"
v-if="Object.keys(scope.row.sip_add).length>0"
popper-class="IPDetailsPopover"
>
<IPDetails ref="ipdetails" :info="info"/>
<el-button
type="text"
icon="el-icon-search"
slot="reference"
@click="toggleIPDetailsDialog(scope.$index,'sip')"
>
</el-button>
</el-popover>
</div>
<div v-for="item in scope.row.sip_location" :key="item">
<div style="margin-bottom:2px">
<el-tag effect="dark" color="#199fc7" size="mini" span="2" style="width:100%">{{
item
}}</el-tag>
</div>
</div>
</template>
</el-table-column>
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)