vue-router和location.href的用法区别
发布时间:2022-09-23 17:46:15
发布人:qyf

· vue-router使用pushState进行路由更新,静态跳转,页面不会重新加载;
· location.href会触发浏览器,页面重新加载一次
· vue-router使用diff算法,实现按需加载,减少dom操作
· vue-router是路由跳转或同一个页面跳转;location.href是不同页面间跳转;
· vue-router是异步加载this.$nextTick(()=>{获取url});location.href是同步加载