早睡早起,方能养生
Sleep early rise early, way to keep healthy

uniappAPP与webview子页面交互

super
2022-02-14 20:46
views 4010

Uniapp

 

<template>
	<view>
	    <web-view @message="reciveMessage" :webview-styles="webviewStyles" :src="src"></web-view>
	</view>
</template>

 

data() {
	return {
		webviewStyles: {
			progress: {
				color: '#FF3333'
			}
		},
		src: 'webview页面链接'
	}
},
methods:{
	reciveMessage(data) {
		console.log(data);
		let url = data.detail.data[0].url;

		// plus.runtime.openURL(url)
	}
}

 

Html代码

 

<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
<script>

    function goUrl(value) {

        uni.postMessage({
            data: {
                url : value
            }
        })
    }

</script>

 

 



分享
0 条讨论
top