vue.js實現彈窗功能的方法:【document.addEventListener('mouseup',(e)=>{var _con = document.getElementById('children-view')if(_c...】。
本文操作環境:windows10系統、vue.js 2.9、thinkpad t480電腦。
實現思路:
在點擊完之后點擊其他位置跳轉路由,路由跳轉后利用computed屬性監聽$route進行class的顯示和隱藏,利用的是js Contains方法
實現代碼:
document.addEventListener('mouseup',(e)=>{ var _con = document.getElementById('children-view') if(_con && !_con.contains(e.target){ this.$route.push({ name:"Index" }) } })
以上就是vue.js如何實現彈窗功能的詳細內容。(拼多多培訓)