业务需求 在VUE页面append 测试页/hybrid/html/local.html,如何监听postMessage,不是用web-view
因为web-view默认全屏,不能设置大小
<template>
<view>
<text>{{testext}}</text>
</view>
</template>
<script>
export default {
data() {
return {
testext:''
};
},
onLoad() {
this.gettext();
},
methods: {
gettext(){
var pages = getCurrentPages();
var page = pages[pages.length - 1];
var currentWebview = page.$getAppWebview();
var w = plus.webview.create('/hybrid/html/local.html','id',{width:'400px',height:'200px'});
currentWebview.append(w);
}
}
}
</script>
<style>
</style>
现在如何实时监听到 /hybrid/html/local.html 发送的数据?
各路大神,有没有办法呢?
2 个回复
y***@qq.com (作者)
另外做了个测试
这个是可以监听
模拟了以前的 mui.fire 注册一个事件(/hybrid/html/local.html)
本页的话可以正常document.addEventListener,但在vue不知道这个receive函数怎么写,写在哪?
都提示 receive is not defined
y***@qq.com (作者)
没人回,暂时用 plus.storage.getItem解决了,还不知道APP端通平台没有
叫我白老师
遇到了一样的问题,
后来用global解决了
global.receive=function(){ ... }
不过要注意parent别弄错了
2019-04-24 14:03
i***@qq.com
同样遇到了,怎么弄的,给几行代码呗,谢谢啦
当前页和子webview相互发信息
2019-05-04 23:08
1***@qq.com
回复 叫我白老师: 您好, 可以说的详细点吗?
2019-05-24 16:41