【发布时间】:2020-12-11 14:53:30
【问题描述】:
我想在用户离开窗口时打开一个 v-dialog。
我已经实现了:
<v-dialog v-model="showPopinAlert">
<v-card>alert</v-card>
</v-dialog>
在脚本中,我在 mount() 中有事件:
data () {
return {
showPopinAlert : false
}
},
mounted () {
document.body.addEventListener('mouseleave', function (event) {
if (event.clientY <= 0 || event.clientX <= 0 || (event.clientX >= window.innerWidth || event.clientY >= window.innerHeight)) {
this.showPopinAlert = true
console.log('leaving')
}
})
},
当光标离开正文时,我在控制台中有跟踪,但没有显示 v-dialog。我尝试使用 :key 或 v-if 强制刷新,但它不会改变任何内容
【问题讨论】:
标签: vue.js vuetify.js