fps2tao

微信小程序分享功能的实现方法有两种:

第一种 
在page.js中实现onShareAppMessage,便可在小程序右上角选择分享该页面

onShareAppMessage: function () {

    return {
        title: \'弹出分享时显示的分享标题\',
        desc: \'分享页面的内容\',
        path: \'/page/user?id=123\' // 路径,传递参数到指定页面。
    }

}

 

第二种
自定义按钮实现分享,在page中添加一个带有open-type=’share’的button标签(<button open-type=’share’><\/button>)。点击该按钮后,即会自动触发已经在page.js中定义好的onShareAppMessage方法,实现分享功能。

<button open-type=\'share\'>分享</button>

获取分享传递的参数

如上例,path属性指向的是user页面,并附带id=123的参数。我们只需在user.js的onLoad函数中,通过options查看传递过来的参数:

// user.js
Page({
    onLoad: function(options) {
        console.log(options);
    }
})

 

 

转: https://blog.csdn.net/sinat_41917956/article/details/80606459

 

分类:

技术点:

相关文章:

  • 2021-12-01
  • 2021-08-31
  • 2021-09-23
  • 2021-11-04
  • 2021-11-18
  • 2021-06-23
  • 2021-11-30
  • 2021-12-01
猜你喜欢
  • 2021-12-10
  • 2021-12-01
  • 2021-11-21
  • 2021-12-01
  • 2021-08-27
  • 2021-12-03
  • 2022-01-01
相关资源
相似解决方案