zl程序教程

您现在的位置是:首页 >  前端

当前栏目

vue-router 的原理

Vue原理 Router
2023-09-14 09:00:16 时间

1. hash

修改的时候:history.pushState('名字', null, '/xxx') || location.hash = '/xxx'

回退的时候:window.addEventListener('statepop' || 'hashchange')

 

2. history

修改的时候:history.pushState('名字', null, '/xxx')

回退的时候:window.addEventListener('statepop')