在app.js页面中的onLaunch里添加以下代码
//重写分享方法
wx.onAppRoute(function (res) {
//获取加载的页面
let pages = getCurrentPages(),
//获取当前页面的对象
view = pages[pages.length - 1],
data;
if (view) {
data = view.data;
console.log('是否重写分享方法', data.isOverShare);
if (!data.isOverShare) {
data.isOverShare = true;
view.onShareAppMessage = function () {
//分享配置
return {
title: '标题', // 子页面的title
path: 'pages/index/index',
imageUrl: '/images/logo.png'
};
}
}
}
})
效果: