html52.com
我爱小程序-开发者交流社区

tab页面加载webview,切换tab刷新webview后vconsole提示只能存在一个web

框架类型 问题类型 操作系统版本 手机型号 微信版本
小程序 Bug ios 华为 6.53

index.wxml中

<view wx:for="{{loadCount}}" wx:for-index="index">
    <web-view src="{{url}}" wx:if="{{loadCount==index+1}}"></web-view>
    </view>

index.js中代码

Page({
    data: {
    url:"",
    loadCount:0
    },
    onLoadfunction (options{
    },
    onReadyfunction () {
    },
    onShowfunction () {
    this.data.loadCount++
    this.setData({
    url"https://www.baidu.com/?" + this.data.loadCount,
    loadCountthis.data.loadCount
    })
    },
    onHidefunction () {
    },
    onUnloadfunction () {
    },
    onPullDownRefreshfunction () {
    },
    onReachBottomfunction () {
    },
    onShareAppMessagefunction () {
    }
    })

以上代码好处是随意进入H5的链接。在切换tab返回时候会回到首页并且没有返回历史记录。

问题是,第一次切换的时候会变空白,console提示一个页面只允许存在一个webview,但是第二次切换的时候就正常没这个提示。现在相当于每个tab要切换两次之后才是正常的。安卓苹果都是一样。

附代码片段:https://developers.weixin.qq.com/s/x0OnqAmN7ACg

在开发者工具是正常的。使用真机调试需要二次切换tab之后才正常!

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付