table表格中使用el-popover 無效問題解決方法
table表格中使用el-popover 無效問題解決方法
實例只針對單個的按鈕管用在表格里每一列都有el-popover相當于是v-for遍歷了 所以我們在觸發(fā)按鈕的時候并不是單個的觸發(fā)某一個

主要執(zhí)行 代碼
<el-popover placement="left" :ref="`popover-${scope.$index}`"> 動態(tài)綁定了ref
關(guān)閉彈窗 執(zhí)行deltaskList
<el-table-column align="center" label="操作" fixed="right" width="300px">
<!-- v-buttonShow="5010403" -->
<template slot-scope="scope">
<el-popover placement="left" :ref="`popover-${scope.$index}`">
<div style="border-bottom: 1px solid #ebeef5; margin-bottom: 10px; padding-bottom: 6px">設置賬期</div>
<div style="display: flex; flex-direction: column">
僅記錄賬期,并不會影響出賬流程~
<el-select
v-model="setAccountVal"
clearable
filterable
placeholder="請選擇結(jié)算方式"
style="width: 260px; margin-top: 15px"
size="small"
>
<el-option
v-for="(item, index) in paymentTermsList"
:key="index"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</div>
<div style="text-align: right; margin: 0px; margin-top: 15px">
<el-button type="text" @click="deltaskList(scope.$index)">取消 </el-button>
<el-button size="small" type="primary" @click="popConfirmSub(scope.$index)">確定 </el-button>
</div>
<el-button
style="margin-left: 10px"
slot="reference"
type="text"
v-if="mode == '0'"
@click="setAccountBtn(scope.row)"
>設置賬期</el-button
>
</el-popover>
</template>
</el-table-column>
// 設置賬期
setAccountBtn (row, index) {
let findItem = this.paymentTermsList.find((item) => item.name === row.paymentTerms)
this.setAccountVal = findItem.value
this.setAccountBtnRow = row
},
// 確定
async popConfirmSub (index) {
if (this.setAccountVal === '') return this.$message.error('請選擇賬期')
await newFranchiseeCustomerPaymentTermsEdit({
orgOwner: this.setAccountBtnRow.orgOwner,
paymentTerms: this.setAccountVal
})
this.$message.success('操作成功')
this.deltaskList(index)
this.querySubmit(1)
},
// 取消
deltaskList (index) {
this.$refs[`popover-${index}`].doClose()
}el-popover無法彈出的問題解決
1、不能再el-popover上?使?v-if進?顯?隱藏,應該?v-show
2、在每?個el-popover上都增加?個ref確定每個el-popover都是唯?的,
:ref="`node-popover-${scope.row.id}`"
3、需要使?slot="reference"定義由哪個元素觸發(fā)事件。
除此之外,還有一種特殊情況就是在table使用el-popover也可能會無法彈出,原因是在table中如果有兩行的key是相同的,那么table就不會對這一行再進行一次渲染,如果第一行沒有使用到el-popover組件,那么與它key相同的所有行都不會再進行渲染。
所以,再table中使用el-popover時,一定要保證每一行的key都是唯一的。
到此這篇關(guān)于table表格中使用el-popover 無效問題解決方法的文章就介紹到這了,更多相關(guān)table表格 el-popover 無效問題內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用Vue?Query實現(xiàn)高級數(shù)據(jù)獲取的示例詳解
構(gòu)建現(xiàn)代大規(guī)模應用程序最具挑戰(zhàn)性的方面之一是數(shù)據(jù)獲取,這也是?Vue?Query?庫的用途所在,下面就跟隨小編一起學習一下如何利用Vue?Query實現(xiàn)高級數(shù)據(jù)獲取吧2023-08-08
vue內(nèi)置組件transition簡單原理圖文詳解(小結(jié))
這篇文章主要介紹了vue內(nèi)置組件transition簡單原理圖文詳解(小結(jié)),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-07
vue,angular,avalon這三種MVVM框架優(yōu)缺點
本文給大家具體分析了下vue,angular,avalon這三種MVVM框架優(yōu)缺點,十分的細致全面,有需要的小伙伴可以參考下2016-04-04
詳解vue的數(shù)據(jù)劫持以及操作數(shù)組的坑
這篇文章主要介紹了vue的數(shù)據(jù)劫持以及操作數(shù)組的坑,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04

