这是我的实现方案:
wx.shareAppMessage({
title: '???????????????',
query: `roomId=${roomId}`,
imageUrl: cc.url.raw('resources/pic/sp_share.png'),
success: () => {
this.target.onShareSuccess();
},
fail: () => {
this.target.onShareFail();
}
});
然后share的图片路径build-templates\wechatgame\res\raw-assets\resources\pic\sp_share.png
这么做的目的有两点:
- 放到resource目录下,可以通过路径访问到
- 放到build-templates里面是为了避免对资源做md5的时候把图片名字给改了,导致获取不到
关于build-templates出门左转—>>>http://docs.cocos.com/creator/manual/zh/publish/custom-project-build-template.html?h=build-templa