Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

小程序web-view 如何重载连接或者刷新?

用h5写了几个页面,一个列表A,一个新增B,从A进入B新增后,使用wx.miniProgram.navigateBack({ delta: 1 })返回A页面,A页面是不会刷新的,就是我清除了web-view 的url 判断赋值,但是h5也是没有重载,造成我从B新增后到A无法拿到数据。如果使用跳转从B返回A的话就乱了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
// 监听 wx 小程序页面回调
const callback = () => {
  WeixinJSBridge.on('onPageStateChange', function (res) {
    // 此处触发页面返回更新
  })
}
if (typeof WeixinJSBridge === 'object' && typeof WeixinJSBridge.invoke === 'function') {
  callback()
} else {
  if (document.addEventListener) {
    document.addEventListener('WeixinJSBridgeReady', callback, false)
  } else if (document.attachEvent) {
    document.attachEvent('WeixinJSBridgeReady', callback)
    document.attachEvent('onWeixinJSBridgeReady', callback)
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...