fix: fix target clear logic

This commit is contained in:
Justineo
2021-10-20 10:59:36 +08:00
parent 483e4b6c67
commit e06e507702
2 changed files with 18 additions and 13 deletions

View File

@@ -1,15 +1,19 @@
let target
function clearTarget () {
if (!target) {
return
}
delete target.dataset.target
}
export default ({ app }) => {
let target
document.documentElement.addEventListener('click', () => {
if (!target) {
return
}
delete target.dataset.target
})
document.documentElement.addEventListener('click', clearTarget)
app.router.afterEach(to => {
clearTarget()
if (!to.hash) {
return
}