mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 03:11:15 +00:00
fix(@vant/cli): should allow to click anchor (#9434)
* fix(@vant/cli): should allow to click anchor * chore: add
This commit is contained in:
@@ -17,6 +17,24 @@ export default {
|
||||
return this.$route.name;
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
const anchors = [].slice.call(this.$el.querySelectorAll('h2, h3, h4, h5'));
|
||||
anchors.forEach((anchor) => {
|
||||
anchor.addEventListener('click', this.scrollToAnchor);
|
||||
});
|
||||
},
|
||||
|
||||
methods: {
|
||||
scrollToAnchor(event) {
|
||||
if (event.target.id) {
|
||||
this.$router.push({
|
||||
name: this.$route.name,
|
||||
hash: '#' + event.target.id,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user