mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-09 04:31:35 +08:00
site: robust scroll by hash
This commit is contained in:
parent
6870bb2777
commit
e8355e5074
@ -29,12 +29,6 @@ export default {
|
||||
onMounted(() => {
|
||||
loadingBarApiRef.value = loadingBar
|
||||
loadingBar.finish()
|
||||
const memoedHash = window.location.hash
|
||||
if (memoedHash) {
|
||||
// scroll to hashed element
|
||||
window.location.hash = ''
|
||||
window.location.hash = memoedHash
|
||||
}
|
||||
})
|
||||
return {
|
||||
isXs: isXsRef
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { nextTick } from 'vue'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
export const loadingBarApiRef = {}
|
||||
@ -22,6 +23,12 @@ export default function createDemoRouter (app, routes) {
|
||||
if (loadingBarApiRef.value) {
|
||||
loadingBarApiRef.value.finish()
|
||||
}
|
||||
if (to.hash) {
|
||||
nextTick(() => {
|
||||
const el = document.querySelector(to.hash)
|
||||
if (el) el.scrollIntoView()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user