版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_42460570/article/details/83541532
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 来实现 点击分享