mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(@vant/cli): failed to scroll to anchor (#8379)
This commit is contained in:
parent
f7706fb179
commit
3554cfd9d9
@ -83,6 +83,17 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.$route.hash) {
|
||||
this.$nextTick(() => {
|
||||
const el = document.querySelector(this.$route.hash);
|
||||
if (el) {
|
||||
el.scrollIntoView();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setTitleAndToogleSimulator() {
|
||||
let { title } = this.config;
|
||||
@ -104,7 +115,11 @@ export default {
|
||||
|
||||
document.title = title;
|
||||
|
||||
this.hasSimulator = !(config.site.hideSimulator || this.config.hideSimulator || (current && current.hideSimulator));
|
||||
this.hasSimulator = !(
|
||||
config.site.hideSimulator ||
|
||||
this.config.hideSimulator ||
|
||||
(current && current.hideSimulator)
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -1,17 +0,0 @@
|
||||
export function scrollToAnchor(selector) {
|
||||
let count = 0;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
const el = document.querySelector('#' + selector);
|
||||
if (el) {
|
||||
el.scrollIntoView();
|
||||
clearInterval(timer);
|
||||
} else {
|
||||
count++;
|
||||
|
||||
if (count > 10) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user