Elemenu中el-table中使用el-popover選中關(guān)閉無效解決辦法(最新推薦)
Elemenu中el-table中使用el-popover選中關(guān)閉無效解決辦法
主要是技術(shù)太菜,沒找到原因,一點(diǎn)點(diǎn)才找到這個(gè)辦法解決
因?yàn)樵趀l-table-column里,因?yàn)槭嵌嘈?使用trigger="manual" 時(shí),用v-model="visible"來控制時(shí),控件找不到這個(gè)值,才換成trigger="click"
先找到彈出關(guān)閉事件,再找元素的屬性
右鍵>審核元素,找到他的單擊事件,里面就有關(guān)閉的屬性
使用ref定位,js中根據(jù)ref修改是否顯示showPopper = false;
頁(yè)面大概代碼
<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
項(xiàng)目場(chǎng)景:
原因分析:
在el-table使用el-popover時(shí)不能簡(jiǎn)單的按照官網(wǎng)給的實(shí)例操作 實(shí)例只針對(duì)單個(gè)的按鈕管用在表格里每一列都有el-popover相當(dāng)于是v-for遍歷了 所以我們?cè)谟|發(fā)按鈕的時(shí)候并不是單個(gè)的觸發(fā)某一個(gè)
解決方案:
方法一:
<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)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue綁定class和綁定內(nèi)聯(lián)樣式的實(shí)現(xiàn)方法
本文主要介紹了Vue綁定class和綁定內(nèi)聯(lián)樣式的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11elementplus?中?DatePicker?日期選擇器樣式修改無效的問題及解決方案
這篇文章主要介紹了elementplus中DatePicker日期選擇器樣式修改無效的問題,DatePicker日期選擇器彈出面板默認(rèn)掛載在body上,所以在組件中添加了?scoped?屬性的?style?標(biāo)簽下是修改不到其樣式的,講解了datepicker的使用方法,及常見的配置項(xiàng)和對(duì)應(yīng)的值,需要的朋友可以參考下2024-01-01vue的url請(qǐng)求圖片的問題及請(qǐng)求失敗解決
這篇文章主要介紹了vue的url請(qǐng)求圖片的問題及請(qǐng)求失敗解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09vue實(shí)現(xiàn)點(diǎn)擊追加選中樣式效果
今天小編就為大家分享一篇vue實(shí)現(xiàn)點(diǎn)擊追加選中樣式效果,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11Vue 頁(yè)面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼
這篇文章主要介紹了 Vue 頁(yè)面跳轉(zhuǎn)不用router-link的實(shí)現(xiàn)代碼,文中給大家介紹了vue router-link跳轉(zhuǎn)傳值示例,需要的朋友可以參考下2018-04-04webpack如何打包一個(gè)按需引入的vue組件庫(kù)
在vue項(xiàng)目開發(fā)中,我們會(huì)將經(jīng)常用到的邏輯或模塊抽象成組件,對(duì)于那些多個(gè)項(xiàng)目都有用到的組件,可以考慮封裝成組件庫(kù),這篇文章主要給大家介紹了關(guān)于webpack如何打包一個(gè)按需引入的vue組件庫(kù)的相關(guān)資料,需要的朋友可以參考下2022-02-02