百度智能小程序 页面的事件处理函数
2020-09-05 14:45 更新
onShareAppMessage
解释:页面的事件处理函数,用户点击右上角转发。
Web 态说明:Web 态小程序暂不支持。
详情参见页面相关事件处理函数。
示例
代码示例 1
<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'
}
},
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;
}
}
}
});
以上内容是否对您有帮助:
更多建议: