Sam888
Sam888
  • 发布:33 分钟前
  • 更新:33 分钟前
  • 阅读:10

【报Bug】uniapp开发的h5 用在uniapp webview中无法通信,安卓iOS均正常 

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Win11

HBuilderX类型: 正式

HBuilderX版本号: 4.85

浏览器平台: Chrome

浏览器版本: 鸿蒙next

项目创建方式: HBuilderX

操作步骤:

<template>
<view class="content">
<view class="text-area">
<text class="title">{{title}}</text>
</view>
<view class="" @click="post">
发送消息
</view>
</view>
</template>

<script>
import y_uni from "y_uniwebview"
export default {
data() {
return {
title: 'h5Uniapp'
}
},
onLoad() {

    },  
    methods: {  
        post() {  
            console.log("din", y_uni);  
            y_uni.postMessage({  
                data: {  
                    action: 'message',  
                    data: 'hellosam'  
                }  
            });  
        }  
    }  
}  

</script>

<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.logo {  
    height: 200rpx;  
    width: 200rpx;  
    margin-top: 200rpx;  
    margin-left: auto;  
    margin-right: auto;  
    margin-bottom: 50rpx;  
}  

.text-area {  
    display: flex;  
    justify-content: center;  
}  

.title {  
    font-size: 36rpx;  
    color: #8f8f94;  
}  

</style>

预期结果:

<web-view id="webview" :src="biaoxunUrl" @load="loadedWebView" @message="message"
@onPostMessage="message"></web-view>
message(e) {
console.log(e.detail.data);
let action = e.detail.data[0].action
console.log(action);}

实际结果:

message(e) {
console.log(e.detail.data);
let action = e.detail.data[0].action
console.log(action);方法不调用

bug描述:

uniapp开发的h5 用在uniapp webview中通信不生效

33 分钟前 负责人:无 分享
已邀请:

要回复问题请先登录注册