Vue-Router常见题解--待补充

146 阅读1分钟

1.history.pushState和history.push区别

  • history.pushState IE10后才支持,不会向服务器发送请求,只会改变地址栏的地址,同时把这个地址加入到历史记录中。
  • history.push 地址栏会发生变化,会向服务器发送请求。

2.Vue-Router hash和history原理的区别

  • hash模式基于锚点,通过onHashChange事件进行监听。

  • history模式是基于Html5中的history.pushState(),history.replaceState()方法。

3.问题---提问

  • vue-router的实现里面,this.$router.data.current = this.to,虽然data是响应式的,是什么机制触发了视图的更新。