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>

    就可以触发了

  • 相关阅读:
    设计模式--工厂模式
    docker
    学习的网址
    showslow小记
    .Net学习线路图
    《掌握软件测试九大技术》
    Apache和Tomcat
    Visual Studio 2017 更新到15.3后 提示错误:包含了重复的“Compile”项 的解决方法
    Asp.Net Core MVC项目实现多语言(Globalization/Localization)
    7月23日 会议纪要(项目有重要变动)
  • 原文地址:https://www.cnblogs.com/lizhao123/p/11558674.html
Copyright © 2011-2022 走看看