onShareAppMessage
是实现微信小程序分享功能的方法
Page({
//分享页面
onShareAppMessage: function () {
var that = this;
return {
title: '分享页面',
path: '/pages/index/index?id='+that.data.id,
}
}
})
title
:是我们分享出去页面的标题,
path
:是我们分享页面的路径,
平时我们分享是会遇见一些问题就是 分享出去的页面没有内容 那是因为分享时没有拼接参数,如果页面
需要id参数的话 我们分享时一定也要拼接到url里 这样页面才能正常打开。
<button catchtap='onShareAppMessage' open-type='share'>
如果我们需要点击分享的话 可以直接使用button
组件 open-type='share'
调用onShareAppMessage
来实现 点击分享
喜欢上方小程序,需要源码的,私信小编留下邮箱。