- onShareAppMessage
- 示例
- 代码示例
- 代码示例
- 示例
onShareAppMessage
解释:页面的事件处理函数,用户点击右上角转发。
详情参见页面相关事件处理函数。
示例
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
代码示例
- SWAN
- JS
<view class="wrap"><view class="card-area"><view class="tip-week">发送内容(以下字段可自由适配)</view><view class="list-area"><view class="list-item-key-4">标题</view><input class="list-item-value" bindinput="dataInput" data-type="title" value="{{shareData.title}}" type="text" placeholder="请输入key" /></view><view class="list-area"><view class="list-item-key-4">内容</view><input class="list-item-value" bindinput="dataInput" data-type="content" value="{{shareData.content}}" type="text" placeholder="请输入key" /></view><view class="list-area"><view class="list-item-key-4">跳转页面</view><input class="list-item-value" bindinput="dataInput" data-type="path" value="{{shareData.path}}" type="text" placeholder="请输入key" /></view><button type="primary" open-type="share" hover-stop-propagation="true">点击打开分享面板</button><view class="tip-week">点击右上角菜单或者点击button转发给好友</view></view></view>
Page({data: {shareData: {title: '小程序标题',content: '世界很复杂,百度更懂你',path: 'api/onShareAppMessage/onShareAppMessage',imageUrl: 'https://b.bdstatic.com/miniapp/images/bgt_icon.png'}},onShareAppMessage() {this.data.shareData.path += '?fr=shareApp';return this.data.shareData;},dataInput(e) {let type = e.currentTarget.dataset.type;let dataInput = e.detail.value;switch (type) {case 'title':let title = 'shareData.title';this.setData({[title]: dataInput});break;case 'content':let content = 'shareData.content';this.setData({[content]: dataInput});break;case 'path':let path = 'shareData.path';this.setData({[path]: dataInput});break;}}});


![晴川云Minecraft Wiki教程:初始资源[ ],晴川云](https://baike.qcidc.com/wp-content/uploads/2025/09/20250919082226497-u_2935034094_3263281832fm_253fmt_autoapp_120f_JPEG.jpeg)







暂无评论内容