uni-app:微信小程序:分享给微信好友和分享到朋友圈(hbuilderx 3.7.3)
一,代码:
<template> <view> <view style="margin-left: 20rpx;margin-top: 20rpx; width:710rpx;height:710rpx;background: gray;"> <image class="banner" mode="aspectFit" src="https://img.lhdtest.com/ware/slider/1908.jpg" /> </view> <button class="shareBtn" type="default" data-name="shareBtn" open-type="share"> 分享 </button> </view> </template> <script> export default { data() { return { } }, onLoad(){ //设置Menus菜单,使 发送给朋友/分享到朋友圈 两个按钮可以使用 wx.showShareMenu({ withShareTicket:true, menus:["shareAppMessage","shareTimeline"] }) }, //发送给微信好友 onShareAppMessage(res) { console.log("分享:from:"+res.from); return { title: '中学古诗词背诵', //分享的名称 path: '/pages/share/share', //页面的路径 } }, //分享到朋友圈 onShareTimeline(res) { return { title: '今天背诵了唐代诗人李白的《夜宿山寺》', type: 0, path: '/pages/share/share', imageUrl: "https://img.lhdtest.com/ware/slider/1908.jpg",
} }, methods: { } } </script> <style> .banner { width:100%; height:100%; } </style>
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/05/uniapp-wei-xin-xiao-cheng-xu-fen-xiang-gei-wei-xin-hao-you/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,测试效果:
三,查看hbuilderx的版本:

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2021-02-24 spring boot:从yaml配置文件中读取数据的四种方式(spring boot 2.4.3)