howToBuildMyVueRouter
howToBuildMyVueRouter copied to clipboard
history模式的一些疑惑
看了你的文章,感觉收获颇多。但还是有些疑惑:
为什么在开始的原生JS代码实现的时候,有拦截History模式下的a标签链接的跳转,但在后面vue的时候没有这样做?不是说通过pushState/replaceState或a标签改变 URL 不会触发 popstate 事件吗?为什么可以直接 window.addEventListener("popstate",()=>{ this.history.current = location.pathname }),并且在渲染a标签的时候,也没有阻止链接的跳转啊? return h('a',{attrs:{href:to}},this.$slots.default)