Skip to content

在beforeEach中使用next(path)后,手动改变url中的hash或点击<a href="#/p1">这种形式的链接无法跳转 #856

Closed
@x531tanxl

Description

@x531tanxl

重现url:https://jsfiddle.net/3ja5Lvb9/Lmf9yy0u/2/ ,点击 p1-hash 不生效,但url上的hash已经改变了。

通过调试源代码发现没有绑定hashchange事件。

vue版本:2.0.3,vue-router版本:2.0.1。


这种情况下这里绑定事件的回调未执行:

this.transitionTo(getHash(), function () {
  window.addEventListener('hashchange', function () {
    this$1.onHashChange()
  })
})

Activity

MrRoshan

MrRoshan commented on Nov 9, 2016

@MrRoshan

碰到了同样的问题,使用hash mode的时候,如果在beforeEach中next(path)优先于next()执行,导致页面回退、跳转无法正常执行,原因是window注册hashchange代码未执行

yyx990803

yyx990803 commented on Nov 13, 2016

@yyx990803
Member

This is fixed as a side effect of merging #797 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yyx990803@x531tanxl@fnlctrl@MrRoshan

        Issue actions

          在beforeEach中使用next(path)后,手动改变url中的hash或点击<a href="#/p1">这种形式的链接无法跳转 · Issue #856 · vuejs/vue-router