Skip to content

[2.0] beforeRouteEnter's next(vm => { }) callback not always works #779

Closed
@fy0

Description

@fy0

This bug this about different path with the same component.

index.vue

<template>
  <div>
    <router-link :to="{ path: '/' }">root</router-link>
    <router-link :to="{ path: '/a' }">a</router-link>
    <router-link :to="{ path: '/b' }">b</router-link>
  </div>
</template>
  beforeRouteEnter: (to, from, next) => {
    console.log(111)
    next(vm => {
      console.log(222,  vm) // <- this not always be printed
    });
  }

main.js

import Index from './index.vue'

Vue.use(VueRouter)

var routes = [
    { path: '/', component: Index },
    { path: '/a', component: Index },
    { path: '/b', component: Index },
]

var router = new VueRouter({
    routes: routes
})

Then access / and just switch between a and b, "222" never be printed.
I already tested it on a new empty project generated by vue-cli. I'll upload that if you need.

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

    Issue actions