Skip to content

router.back Can't work when the popstate listener is removed #3371

@citrusjunoss

Description

@citrusjunoss

Version

3.4.9

Reproduction link

#2016

Steps to reproduce

It's a strange problem and it's hard to reproduce。

I found that the problem may lie inhook:destroyedC through breakpoint debugging

    app.$once('hook:destroyed', () => {
      // clean out app from this.apps array once destroyed
      const index = this.apps.indexOf(app)
      if (index > -1) this.apps.splice(index, 1)
      // ensure we still have a main app or null if no apps
      // we do not release the router so it can be reused
      if (this.app === app) this.app = this.apps[0] || null

      if (!this.app) this.history.teardown()
    })

this.appIs set to null, when the app is destroyed for some reason

What is expected?

router.back () works

What is actually happening?

the page is normal, just router.back () or router.go (- 1) not working, which is strange


The code fragment cannot be provided because it is not required

The secondary routing component uses the keepAlive

    <transition name="fade" mode="out-in">
      <keep-alive :max="2" :exclude="excludeViews" :include="includeViews">
        <router-view :key="key"></router-view>
      </keep-alive>
    </transition>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions