uniapp webview h5 执行 uniappjsbridgeready 无用 繁體版
原文   原文链接

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

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

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

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

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

<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>

就能够触发了api

相关文章
相关标签/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公众号
   欢迎关注本站公众号,获取更多信息