uni-app 在APP端实现微信分享


在 manifest.json 的 App SDK 配置里,勾选微信消息及朋友圈,并填写 appid,在iOS平台使用还需要配置通用链接。

参考文档

微信 appid 申请步骤:https://ask.dcloud.net.cn/article/208

iOS平台微信SDK配置通用链接:https://ask.dcloud.net.cn/article/36445

 

 

 

分享到微信聊天界面代码:

html代码:

<button @click="appToShare">分享名片</button>

 

JS代码:

appToShare: function() {
      uni.share({
	        provider: 'weixin',//分享服务提供商(即weixin|qq|sinaweibo)
	        scene: "WXSceneSession",//WXSceneSession(分享到聊天界面)、WXSenceTimeline(分享到朋友圈)、WXSceneFavorite(分享到微信收藏)
		type: 1,
		title: '分享标题',
		summary: "分享描述",
		href: 'www.baidu.com',//分享跳转地址
		imageUrl: '',//分享图片路径(必须是线上可访问图片:http://xxx、https://xxx等)
		success: function(res) {
			console.log("success:" + JSON.stringify(res));
		},
		fail: function(err) {
			console.log("fail:" + JSON.stringify(err));
		}
	});
}

 

 

 

uni-app官方地址:https://uniapp.dcloud.io/api/plugins/share

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM