app微信分享

第一步,打开 manifest.json -> App模块权限配置,勾选 Share(分享);
UNI-APP_uni-app app微信分享-小白菜博客
分享方法


<template>
	<view>
		<button open-type="share">按钮分享至好友</button>
	</view>
</template>

<script>
	export default {
		onShareAppMessage(res) {
			return {
				title: '分享标题',
				desc: '自定义分享描述',
				// 分享图片地址
				imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png',
				// 本地页面(请使用全路径)。
				path: '/pages/index/index?id=123',
			}
		}
	}
</script>
shareFriend: function() {
    //分享到微信朋友
     uni.share({ 
         provider: "weixin",
         scene: "WXSceneSession",
         type: 0,
         href: "http:*******************",//跳转链接
         title: "分享内容的标题",
         summary: "分享内容的摘要",                         
         imageUrl: "http:*******************",//图片地址。type为0时,推荐使用小于20Kb的图片
         success: function(res) {
             console.log("success:" + JSON.stringify(res));
         },
         fail: function(err) {
             console.log("fail:" + JSON.stringify(err));
         }
     });
 },

//分享到微信朋友圈
 shareFriendcricle: function() {
     uni.share({
         provider: "weixin",
         scene: "WXSenceTimeline",
         type: 0,
         href: "http:*******************",//跳转链接
         title: "分享内容的标题",
         summary: "分享内容的摘要",
         imageUrl: "http:*******************",//图片地址。type为0时,推荐使用小于20Kb的图片
         success: function(res) {
             console.log("success:" + JSON.stringify(res));
         },
         fail: function(err) {
             console.log("fail:" + JSON.stringify(err));
         }
     });
 }