Elemenu中el-table中使用el-popover選中關(guān)閉無效解決辦法(最新推薦)
Elemenu中el-table中使用el-popover選中關(guān)閉無效解決辦法
主要是技術(shù)太菜,沒找到原因,一點(diǎn)點(diǎn)才找到這個辦法解決
因為在el-table-column里,因為是多行,使用trigger="manual" 時,用v-model="visible"來控制時,控件找不到這個值,才換成trigger="click"
先找到彈出關(guān)閉事件,再找元素的屬性
右鍵>審核元素,找到他的單擊事件,里面就有關(guān)閉的屬性
使用ref定位,js中根據(jù)ref修改是否顯示showPopper = false;
頁面大概代碼
<el-table-column> <template slot-scope="scope"> <el-popover :ref="col.prop+'_'+scope.$index" trigger="click" > <span slot="reference" @click="ev_gytj_clk(scope.row,scope.$index)">{{ scope.row[col.prop] }}</span> </el-popover> </template> </el-table-column>
js代碼
ev_gytj_clkitem(row,index,item){ row.gytj=item //Popper選中關(guān)閉 this.$refs['gytj_' + index][0].showPopper = false },
補(bǔ)充:
解決 el-table使用 el-popover 點(diǎn)擊沒反應(yīng) bug
項目場景:
原因分析:
在el-table使用el-popover時不能簡單的按照官網(wǎng)給的實(shí)例操作 實(shí)例只針對單個的按鈕管用在表格里每一列都有el-popover相當(dāng)于是v-for遍歷了 所以我們在觸發(fā)按鈕的時候并不是單個的觸發(fā)某一個
解決方案:
方法一:
<template slot-scope="scope"> <el-popover placement="top" :ref="`popover-${scope.$index}`"> <p>確定刪除?</p> <div style="text-align: right; margin: 0"> <el-button style="padding: 2px;" size="mini" type="text" ??????? @click="scope._self.$refs[`popover-${scope.$index}`].doClose()">取消 </el-button> <el-button style="padding: 2px;" type="primary" size="mini" @click="deltaskList(scope)">確定 </el-button> </div> <el-button slot="reference" type="text" size="small">刪除</el-button> </el-popover> </template> //方法 deltaskList(e){ e._self.$refs[`popover-${e.$index}`].doClose(); },
方法二:
<template slot-scope="scope"> <el-popover placement="top" :ref="`popover-${scope.$index}`"> <p>確定刪除?</p> <div style="text-align: right; margin: 0"> <el-button style="padding: 2px;" size="mini" type="text" ??????? ??????? ??????? @click="deltaskList(scope.$index)">取消 </el-button> <el-button style="padding: 2px;" type="primary" size="mini">確定 </el-button> </div> <el-button slot="reference" type="text" size="small">刪除</el-button> </el-popover> </template> //方法 deltaskList(index){ this.$refs[`popover-${index}`].doClose() },
方法三:
<template slot-scope="scope"> <el-popover placement="top" v-model="item.row.visible"> <p>確定刪除?</p> <div style="text-align: right; margin: 0"> <el-button style="padding: 2px;" size="mini" type="text" ??????? ??????? ??????? @click="deltaskList()">取消 </el-button> <el-button style="padding: 2px;" type="primary" size="mini" ??????? @click="deltaskList()">確定 </el-button> </div> <el-button slot="reference" type="text" size="small">刪除</el-button> </el-popover> </template> //方法 deltaskList(){ this.$refs.closepopover.click(); },
到此這篇關(guān)于Elemenu中el-table中使用el-popover選中關(guān)閉無效解決辦法的文章就介紹到這了,更多相關(guān)el-table使用el-popover選中關(guān)閉無效內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue綁定class和綁定內(nèi)聯(lián)樣式的實(shí)現(xiàn)方法
本文主要介紹了Vue綁定class和綁定內(nèi)聯(lián)樣式的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-11-11elementplus?中?DatePicker?日期選擇器樣式修改無效的問題及解決方案
這篇文章主要介紹了elementplus中DatePicker日期選擇器樣式修改無效的問題,DatePicker日期選擇器彈出面板默認(rèn)掛載在body上,所以在組件中添加了?scoped?屬性的?style?標(biāo)簽下是修改不到其樣式的,講解了datepicker的使用方法,及常見的配置項和對應(yīng)的值,需要的朋友可以參考下2024-01-01vue實(shí)現(xiàn)點(diǎn)擊追加選中樣式效果
今天小編就為大家分享一篇vue實(shí)現(xiàn)點(diǎn)擊追加選中樣式效果,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11Vue 頁面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼
這篇文章主要介紹了 Vue 頁面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼,文中給大家介紹了vue router-link跳轉(zhuǎn)傳值示例,需要的朋友可以參考下2018-04-04