Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigateBack页面栈问题 #1400

Open
Destinygu opened this issue Feb 19, 2019 · 3 comments
Open

navigateBack页面栈问题 #1400

Destinygu opened this issue Feb 19, 2019 · 3 comments

Comments

@Destinygu
Copy link

[问题简单描述]

问题复现步骤:

a、b页面url前缀均为/pages/dirlist/main

  1. 从首页跳转页面a,url中的id为1
    wx.navigateTo({
    url: '/pages/dirlist/main?id=1'
    })

2、从页面a中跳转到页面b,url为id为2
wx.navigateTo({
url: '/pages/dirlist/main?id=2'
})

3、 navigateBack的时候无法从b页面跳到a页面,页面栈无变化,调用navigateBack闪了一下a页面后继续呈现b页面

期望的表现:

navigateBack能正常返回a页面(用原生的小程序测试过没有该问题,这是mpvue的bug?有什么好的解决方案)

@rchunping
Copy link

const dataStack = []

export default {

          onLoad() {
              // 首先保存data
               dataStack.push(...this.$data)
              
               // 其他初始化.....
          }
          onUnload() {
               // 清理完成后
              
               //  最后恢复data
              dataStack.length && Object.assign(this.$data, dataStack.pop())
          }
}

@Dewyzee
Copy link
Member

Dewyzee commented Feb 19, 2019

@rchunping

const dataStack = []

export default {

          onLoad() {
              // 首先保存data
               dataStack.push({...this.$data})
              
               // 其他初始化.....
          }
          onUnload() {
               // 清理完成后
              
               //  最后恢复data
              dataStack.length && Object.assign(this.$data, dataStack.pop())
          }
}

@khejing
Copy link

khejing commented Mar 15, 2019

参见#140,在官方解决以前,用@HelloZJW 的mpvue-loader分支搭配mpvue-page-factory 可解决这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants