uni-app与小程序分享朋友圈功能实操
1、首先明白,uni-app 与 小程序的工作原理,熟知API文档,在开发中有很大的必要性。[文档:uni-app官方文档]
2、微信朋友圈分享,废话不多说,直接上代码?[小程序API:官方文档]
调用API分享朋友圈: onShareTimeline
onShareTimeline: function(res) {
const data = this.banner
data.find(item => {
this.titlea = item.name;
this.pisa = item.pic;
})
return {
title: this.titlea, //字符串 自定义标题
// query: `id=${this.$yroute.query.id}`, //页面携带参数
path: `/pages/home/index`,
imageUrl: this.pica //图片地址
}
},
调用API分享给好友:onShareAppMessage
onShareAppMessage: function(res) {
const data = this.banner
data.find(item => {
this.titlea = item.name
})
return {
title: this.titlea,
path: `/pages/home/index`,
}
},
调用成功截图
平API要与methods平齐,方可执行。
百尺竿头、日进一步
问题讨论:请留言!
本期配图主题:百变女神陈钰琪小姐姐。
喜欢的点个赞吧~~~