怎么样修改小程序分享的title/onShareAppMessage

 onShareAppMessage: function (res) {
        if (res.from === 'button') {
            // 来自页面内转发按钮
            console.log(res.target)
        }
        return {
            title: '我已0元试用' + this.data.pageTitle + ',你也快来领!',
            path: '/pages/report/report?reportid=' + this.data.reportid
        }
    },

  

 2.点击按钮来分享

  <button  class="sharebutton margin-20" open-type="share"  bindgetuserinfo="share"  plain="true">
      <image src="https://buy.fishqc.com/img/icon-share-default.png" style="34rpx" class="verticalAlign"  mode="widthFix"></image>
  </button>
     onShareAppMessage() {
            var self = this;
            return {
                title: '领补贴更划算丨'+self.detaildata.prdName,
                path: '/pages/shoppingDetail?prdId='+self.prdId+'&openid='+(self.$parent.globalData.openid?self.$parent.globalData.openid:'')
            }      
        }

  通过给 button 组件设置属性 open-type="share",可以在用户点击按钮后触发 Page.onShareAppMessage() 事件,如果当前页面没有定义此事件,则点击后无效果。

原文地址:https://www.cnblogs.com/antyhouse/p/9327745.html