<!-- h5部分代码 -- >
payment() {
const { formData } = this
const uni = window.uni
if (window.UniAppJSBridge) {
uni.postMessage({
data: {
action: 'postMessage'
}
})
} else {
document.addEventListener('UniAppJSBridgeReady', function() {
uni.postMessage({
data: {
message: '我是子页面发出的数据'
}
})
})
}
}
<!-- uni-app 部分代码 -->
onLoad (params) {
// #ifdef APP-PLUS
const sys = uni.getSystemInfoSync()
wv = plus.webview.create("", "custom-webview", {
'uni-app': 'none',
height: '90%',
top: sys.statusBarHeight + 44,
popGesture: 'close',
scrollIndicator: 'none'
})
wv.loadURL('/hybrid/html/index.html')
var currentWebview = this.$scope.$getAppWebview()
currentWebview.append(wv)
uni.setNavigationBarTitle({
title: config.MEMBERSHIP_PAYMENT.title
})
plus.globalEvent.addEventListener('plusMessage', function(msg){
console.log(msg.data.args.data.name)
if(msg.data.args.data.name == 'postMessage'){
console.log(msg.data.args.data.arg);
}
})
// #endif
}