小程序端文章来源:https://www.toymoban.com/news/detail-770756.html
<web-view src="{{path}}" bindmessage="handleWebviewMessage"></web-view>
data: {
path: '',
shareOptionsObj: {},
},
onLoad(options: { webview: string }) {
this.setData({
path: decodeURIComponent(options.webview)
})
},
onShareAppMessage() {
const _this = this
return _this.data.shareOptionsObj
},
handleWebviewMessage(e: WechatMiniprogram.CustomEvent) {
const obj = e.detail.data[e.detail.data.length - 1]
if (obj.type === 'share') {
this.setData({
shareOptionsObj: e.detail.data[e.detail.data.length - 1].config,
})
}
}
H5端文章来源地址https://www.toymoban.com/news/detail-770756.html
<div class="page-transfer-page-container">
<div @click="onShare" class="btn-share">国民家</div>
</div>
import wx from 'weixin-js-sdk' // 引入微信sdk依赖 版本: "weixin-js-sdk": "^1.6.0"
methods: {
onShare() {
wx.miniProgram.postMessage({
data: {
type: 'share',
config: {
title: '国民家',
path: `/pages/webview/index?webview=${encodeURIComponent(
'https://ai.insurtechbank.net/pa-health-ui/#/transferPage',
)}`,
imageUrl:
'https://wallet-minio.lianft.com/picc/miniapp/share/share.png',
},
},
})
},
},
到了这里,关于h5页面调用小程序分享方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!