微信小程序自定义按钮实现分享功能

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38543537/article/details/84791523

在js文件里边最下方有一个onShareAppMessage函数,在这个函数里边添加分享的内容和路径,如下:

/**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {
    return {
      title: '在这里输入标题', 
      desc: '在这里输入简介说明',
      path: '../home/home'//这是一个路径
    }
  }

然后在wxml里边定义一个按钮来触发分享事件,如下:

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

 

自定义的按钮需要在button标签上添加一个open-type='share'属性。

去掉按钮边框方法,如下:

button::after{
  border: none;
}

猜你喜欢

转载自blog.csdn.net/qq_38543537/article/details/84791523