Comments (3)
是个缺陷,页面一进入的时候,读取了 setDefault
设置的默认 url,然后设置 hash,就产生了历史记录,然后就可以后退
from router.
这个问题怎么解决呢
from router.
问题出在 src/index.js 的 44行
window.addEventListener('hashchange', (event) => {
const hash = util.getHash(event.newURL);
const state = history.state || {};
this.go(hash, state._index <= this._index);
}, false);
在执行 * this.go * 之前检验一下新旧hash是否相等就行了,如果相同,说明到达根路由了,直接return即可,因此可以改成这样:
window.addEventListener('hashchange', (event) => {
const old_hash = util.getHash(event.oldURL);
const hash = util.getHash(event.newURL);
// fix '/' repeat see https://github.com/progrape/router/issues/21
if(old_hash === hash) return;
const state = history.state || {};
this.go(hash, state._index <= this._index);
}, false);
pr已经发了,也可以看这里
https://github.com/chux0519/router
from router.
Related Issues (20)
- 有没有设置默认路由,当router里没有路由的时候跳转默认路由 HOT 3
- bind 执行两次 HOT 3
- go方法似乎有点问题
- 关于 render 完成后,需要执行一些代码。 HOT 2
- render重复问题 HOT 3
- 第一次跳转,bind事件执行2次 HOT 4
- 在IOS系统下,打开APP嵌套的weui,偶尔会出现滑不动的情况,其他h5都没问题.
- 想问问模板有什么更好的组织方式 HOT 2
- 当我在页面中使用onclick="window.history.back(-1)"时,会报错找不到url HOT 1
- 在过渡动画中点击新页面的链接时,会造成之前的页面不删除
- 过渡动画的时间问题 HOT 1
- 建议调用bind函数时不要使用call
- 浏览器前进后退按钮点击过快会导致异常
- render()方法中使用promise后可能导至同时渲染两个模板
- 在bind方法中怎么获取到当前的router信息呢?
- 微信端侧滑bug
- go方法死循环
- 能不能支持vue.js
- 可以打包成多个js吗,按需加载js文件 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.