vue-router和location.href的用法区别是什么?

vue-router和location.href的用法区别

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

猜你喜欢

转载自blog.csdn.net/sdasadasds/article/details/128466448
今日推荐