vue2 el-table行懸停時彈出提示信息el-popover的實現(xiàn)
實現(xiàn)方法,用到了cell-mouse-enter、cell-mouse-leave兩個事件,然后在表格的首列字段中,加個el-popover組件,當(dāng)然你也可以選擇在其他字段的位置來顯示提示框,看自己的需求了。

示例代碼:
<el-table @cell-mouse-enter="enter" @cell-mouse-leave="leave" :data="[{rowIndex:100, title:'行一', status: 1},{rowIndex:200, title:'行二', status: 0}]">
<el-table-column label="序號" width="100">
<template slot-scope="scope">
<el-popover trigger="manual" placement="right" :ref="'popover'+(scope.row.rowIndex)">
<div>彈出popover提示內(nèi)容</div>
<div slot="reference">{{ scope.$index+1 }}</div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="標(biāo)題" prop="title"></el-table-column>
</el-table>enter (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = true
},
leave (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = false
}在enter方法中,還可以根據(jù)row行數(shù)據(jù)進(jìn)行一些處理,比如根據(jù)狀態(tài)status來判斷是否彈出提示框。
enter (row, column, cell) {
//當(dāng)status等于0時彈出提示框
if(row.status===0) {
this.$refs['popover' + row.rowIndex].showPopper = true
}
},
leave (row, column, cell) {
this.$refs['popover' + row.rowIndex].showPopper = false
}到此這篇關(guān)于vue2 el-table行懸停時彈出提示信息el-popover的實現(xiàn)的文章就介紹到這了,更多相關(guān)vue2 懸停彈出提示信息內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue利用mockjs編寫假數(shù)據(jù)并應(yīng)用的問題記錄
這篇文章主要介紹了Vue利用mockjs編寫假數(shù)據(jù)并應(yīng)用,本文通過實例代碼給大家詳細(xì)講解,對Vue?mockjs數(shù)據(jù)相關(guān)知識感興趣的朋友跟隨小編一起看看吧2022-12-12
vue-cli對element-ui組件進(jìn)行二次封裝的實戰(zhàn)記錄
組件類似于需要多個地方用到的方法,在Vue中組件就是一種復(fù)用(經(jīng)常使用)一個功能的手段,下面這篇文章主要給大家介紹了關(guān)于Vue?element?ui二次封裝的相關(guān)資料,需要的朋友可以參考下2022-06-06

