詳解vue中在循環(huán)中使用@mouseenter 和 @mouseleave事件閃爍問題解決方法
最近在項目中實(shí)現(xiàn)在循環(huán)出來的圖片中當(dāng)鼠標(biāo)移入隱藏當(dāng)前圖片顯示另一張圖片的需求時碰到了一個小問題。就是當(dāng)使用@mouseenter 和@mouseleave事件來實(shí)現(xiàn)這個需求時卻發(fā)現(xiàn)鼠標(biāo)移入后圖片出現(xiàn)閃爍現(xiàn)象。
重點(diǎn):事件寫到父元素上才行?。。?0.0
下面寫下我的實(shí)現(xiàn)方法和實(shí)現(xiàn)效果
樣式代碼:
<div v-for='(item,index) in exampleUrl' :key = index @mouseenter ='enterFun(index)' @mouseleave ='leaveFun(index)' > <img :src = item.url v-show='show || n != index' > <div v-show='!show && n == index' >查看詳情</div></div>
其他代碼:
export default {data () { return { n: 0, show:true, }} ,methods: {enterFun(index){ console.log(’鼠標(biāo)移入’); this.show = false; this.n = index;},leaveFun(index){ console.log(’鼠標(biāo)離開’); this.show = true; this.n = index;},} }
最終實(shí)現(xiàn)效果如圖 當(dāng)鼠標(biāo)移入圖片時當(dāng)前圖片顯示查看詳情:
到此這篇關(guān)于詳解vue中在循環(huán)中使用@mouseenter 和 @mouseleave事件閃爍問題解決方法的文章就介紹到這了,更多相關(guān)vue @mouseenter @mouseleave事件閃爍內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. python如何換行輸出2. Python使用urlretrieve實(shí)現(xiàn)直接遠(yuǎn)程下載圖片的示例代碼3. Python:UserWarning:此模式具有匹配組。要實(shí)際獲得組,請使用str.extract4. 解決Android Studio 格式化 Format代碼快捷鍵問題5. Java使用Tesseract-Ocr識別數(shù)字6. python如何計算圓的面積7. 詳解java google Thumbnails 圖片處理8. Vue實(shí)現(xiàn)聊天界面9. Android Studio中一套代碼多渠道打包的實(shí)現(xiàn)方法10. Android打包篇:Android Studio將代碼打包成jar包教程
