Linux 拨号vps windows公众号手机端

微信小程序怎么跟H5页面进行交互

lewis 7年前 (2018-12-08) 阅读数 9 #VPS/云服务器
文章标签 h5小程序

在微信小程序实现跟H5页面进行交互的方法

1.使用web-view标签内嵌网页,通过 src 携带参数,通过 @message 接收h5传回的数据实现交互

<template>
<view>
<web-view :src="activity.imgUrl?id=xxx" @message="postMessage"></web-view>
</view>
</template>

2.在h5页面通过 wx.miniProgram.postMessage 向小程序传递参数

<scripttype="text/javascript"src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>

<scripttype="text/javascript">

wx.miniProgram.postMessage({

data:'foo'

})

</script>


版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门