文档
https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareAppMessage-Object-object
代码
https://developers.weixin.qq.com/s/fWowy9mv7ZD7
示例
const app = getApp()
Page({
data: {
},
onLoad() {
console.log('代码片段是一种迷你、可分享的小程序或小游戏项目,可用于分享小程序和小游戏的开发经验、展示组件和 API 的使用、复现开发问题和 Bug 等。可点击以下链接查看代码片段的详细文档:')
console.log('https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/devtools.html')
},
onShareAppMessage(e) {
if (e.from === 'button') {
console.log(e);
return {
title: 'xxxx',
path: '/a/index'
}
}
}
})
index.wxml
<view class="intro">欢迎使用代码片段,可在控制台查看代码片段的说明和文档</view>
<button open-type="share">分享</button>
onShareAppMessage方法不执行
onShareAppMessage中写入和更改分享的信息就可以了