介绍
这篇文章给大家分享的是有关怎么在小程序页面内进行转发操作的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
我们先来看看官方文档上的内容:
官方文档上说通过给按钮组件设置属性开放=皊hare",可以在用户点击按钮后触发页面。onShareAppMessage事件,相关组件:按钮。
官网文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
第一种情况点击小程序转发
不加入参数
,,//转发 ,,onShareAppMessage:函数(),{ ,,,let users =, wx.getStorageSync(& # 39;用户# 39;); ,,,if (res.from ===, & # 39;按钮# 39;),{} ,,,return { ,,,,,标题:,& # 39;转发& # 39;, ,,,,,路径:,& # 39;/页面/索引/指数# 39; ,,,,,:成功,函数(res), {} ,,,} 以前,,}>加入参数
,,//转发 ,,onShareAppMessage:函数(),{ ,,,let users =, wx.getStorageSync(& # 39;用户# 39;); ,,if (res.from ===, & # 39;按钮# 39;),{} ,,,return { ,,,,,标题:,& # 39;转发& # 39;, ,,,,,路径:,& # 39;/页面/索引/索引? from_uid=& # 39;, +, users.id, ,,,,,:成功,函数(res), {} ,,,} 以前,,}>第二种:分享
这个分享必须做成按钮且加上开式=皊hare"
不加入参数
,,onShareAppMessage:, function (res), { ,,,if (res.from ===, & # 39;按钮# 39;),{ ,,,} ,,,return { ,,,,,标题:,& # 39;转发& # 39;, ,,,,,路径:,& # 39;/页面/索引/社区/主题/话题# 39;, ,,,,,成功:,function (res), { ,,,,,,,console.log(& # 39;成功& # 39;,,res) ,,,,,} ,,,} 以前,,}>加入参数
,,//转发 ,,onShareAppMessage: function (res), { ,,,if (res.from ===, & # 39;按钮# 39;),{ , ,,,} ,,,return { ,,,,,标题:,& # 39;转发& # 39;, ,,,,,路径:,& # 39;/页面/索引/社区/主题/主题? jsonStr=& # 39;, +, this.data.list, ,,,,,成功:,function (res), { ,,,,,,,console.log(& # 39;成功& # 39;,,res) ,,,,,} ,,,} 以前,,}>
提醒:这里转发的参数要在onLoad运的选项用
怎么在小程序页面内进行转发操作