1.用户点击分享执行onShareAppMessage函数即可:

2.实例如下:

3.分享分为两种:1.微信小程序自带的页面分享

4.2.自己页面写的分享按钮:buttonopen-type="share"点击分享/button

5.它们共同调用Js如下:

6.onShareAppMessage:function(res){

7.varthat=this

8.if(res.from==='button'){

9.//来自页面内转发按钮

10.console.log(res.target)

11.}

12.return{

13.title:'分享页面的标题',

14.path:'页面路径?参数',

15.//分享成功后执行

16.success:function(res){

17.console.log("--------------转发成功--------------------")

18.}

19.fail:function(res){

20.console.log("--------------转发失败--------------------")

21.}

22.}

23.},

24.注:测试分享成功失败时,建议启动微信小程序开发工具的远程调试进行调试较为明显.

TAG标签: 微信小程序小程序页面分享小程序分享

http://www.xiaochengxub.com/read-98222.html