howToBuildMyVueRouter
howToBuildMyVueRouter copied to clipboard
手写VueRouter核心原理
看了你的文章,感觉收获颇多。但还是有些疑惑: 为什么在开始的原生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)`
https://github.com/Sunny-lucking/howToBuildMyVueRouter/blob/43caaf59e5dce15235f3359e5c7ad15c7b044209/src/router/myVueRouter.js#L76 按这么写的话,在 history 模式下点击链接是会发出请求的,应该用 pushState 来处理?
Bumps [minimist](https://github.com/minimistjs/minimist) from 1.2.5 to 1.2.8. Changelog Sourced from minimist's changelog. v1.2.8 - 2023-02-09 Merged [Fix] Fix long option followed by single dash [#17](https://github.com/minimistjs/minimist/issues/17) [Tests] Remove duplicate test [#12](https://github.com/minimistjs/minimist/issues/12) [Fix]...
Bumps [json5](https://github.com/json5/json5) to 2.2.3 and updates ancestor dependency [@vue/cli-service](https://github.com/vuejs/vue-cli/tree/HEAD/packages/@vue/cli-service). These dependencies need to be updated together. Updates `json5` from 0.5.1 to 2.2.3 Release notes Sourced from json5's releases. v2.2.3 Fix:...
Bumps [express](https://github.com/expressjs/express) from 4.17.1 to 4.18.2. Release notes Sourced from express's releases. 4.18.2 Fix regression routing a large stack in a single route deps: [email protected] deps: [email protected] perf: remove unnecessary...
Bumps [qs](https://github.com/ljharb/qs) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together. Updates `qs` from 6.5.2 to 6.11.0 Changelog Sourced from qs's changelog. 6.11.0 [New] [Fix] stringify: revert 0e903c0; add commaRoundTrip...
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2. Release notes Sourced from decode-uri-component's releases. v0.2.2 Prevent overwriting previously decoded tokens 980e0bf https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2 v0.2.1 Switch to GitHub workflows 76abc93 Fix issue where decode...
Bumps [loader-utils](https://github.com/webpack/loader-utils) to 1.4.2 and updates ancestor dependency [@vue/cli-service](https://github.com/vuejs/vue-cli/tree/HEAD/packages/@vue/cli-service). These dependencies need to be updated together. Updates `loader-utils` from 0.2.17 to 1.4.2 Release notes Sourced from loader-utils's releases. v1.4.2 1.4.2...