1***@qq.com
1***@qq.com
  • 发布:2022-08-05 11:56
  • 更新:2022-08-05 11:56
  • 阅读:913

app-nvue webview加载本地网页,真机上路径错误

分类:uni-app

app-nvue webview加载本地网页,url不能携带参数(如:/hybrid/html/index.html?id=1 改为 /hybrid/html/index.html)。
数据传递使用webview通信。

webview官网:https://uniapp.dcloud.net.cn/component/web-view.html


<template>  
    <view>  
        <web-view ref="webview" class="webview" @onPostMessage="handlePostMessage"></web-view>  
        <button class="button" @click="evalJs">evalJs(改变webview背景颜色)</button>  
    </view>  
</template>  

<script>  
    export default {  
        data: {  
        },  
        methods: {  
            // webview向外部发送消息  
            handlePostMessage: function(data) {  
                console.log("接收到消息:"   JSON.stringify(data.detail));  
            },  
            // 调用 webview 内部逻辑和方法(方法挂载到window对象上)  
            evalJs: function() {  
                this.$refs.webview.evalJs(`方法名(${paramStr})`);  
            }  
        }  
    }  
</script>
0 关注 分享

要回复文章请先登录注册