zoukankan      html  css  js  c++  java
  • uniapp跳转webview后H5不执行UniAppJSBridgeReady 回调无用

    开始时我在真机上测试使用

    <web-view :src="'/hybrid/html/pages/index/index.html?userInfo='+JSON.stringify(userInfo)+'&type='+webViewType" @message="getMessage"></web-view>

    这种形式传参时没有问题会走UniAppJSBridgeReady 回调但是,离线打包生成app资源在xcode上运行到手机出现不回调

    因为官方的demo实例中没有出现问题,因为里面没有向webview传参

    后来发现是传参问题,不能用下面形式

    <web-view :src="'/hybrid/html/pages/index/index.html?userInfo='+JSON.stringify(userInfo)+'&type='+webViewType" @message="getMessage"></web-view>

    我改后的
    <template>
        <view>
            <!-- <web-view :src="'/hybrid/html/pages/index/index.html?userInfo='+JSON.stringify(userInfo)+'&type='+webViewType" @message="getMessage"></web-view> -->
            <web-view :src="url" @message="getMessage"></web-view>
        </view>
    </template>
    
    <script>
        //非父子组件传值
        import bus from '../../static/js/bus.js';
        import { mapState, mapMutations } from 'vuex';
        export default {
            computed: mapState(['userInfo', 'api','webViewType']),
            data() {
                return {
                    url:'',
                    fileList:[]
                }
            },
            onLoad(option) {
                console.log(this.webViewType)
                this.url=`/hybrid/html/pages/index/index.html?type=${this.webViewType}&token=${this.userInfo.token}`
            },
            methods: {
                getMessage(event) {
                    this.fileList=event.detail.data[0].fileList
                    bus.$emit('fileList',this.fileList)
                }
            }
        }
    </script>
    
    <style>
    </style>

    就可以触发了

  • 相关阅读:
    C# Linq 交集、并集、差集、去重
    SpringICO和DI区别
    postman调用webapi错误记录
    NetCore实例提供的依赖注入的生命周期
    ios处理暴力输出问题
    一块国外开源的视频播发器
    一个有创意的3D APP
    Flurry Analytics最近免费添加了获取新用户分析和app崩溃报告的功能
    那些域名服务商
    Moneybookers的优点
  • 原文地址:https://www.cnblogs.com/lizhao123/p/11558674.html
Copyright © 2011-2022 走看看