更新记录
1.0.0(2026-07-02)
- 初始版本
- 支持文本、链接、图片、视频、音频、文件分享
- 支持 Android 和 iOS 平台
平台兼容性
uni-app(5.07)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| - |
- |
- |
- |
- |
- |
5.0 |
14 |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(5.07)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
5.0 |
14 |
- |
- |
cc-share
原生系统级别分享插件,支持 Android 和 iOS 平台。
功能
- 分享文本
- 分享链接
- 分享图片(单张/多张)
- 分享视频(单个/多个)
- 分享音频(单个/多个)
- 分享文件(单个/多个)
平台兼容性
使用方法
import { shareWithSystem } from "@/uni_modules/cc-share"
// 分享文本
shareWithSystem({
summary: "Hello World",
type: 'text',
success(res) {
console.log("分享成功", res.errMsg)
},
fail(err) {
console.log("分享失败", err.errCode, err.errMsg)
}
})
// 分享链接
shareWithSystem({
href: "https://uniapp.dcloud.io",
type: 'text',
success(res) {
console.log("分享成功")
}
})
// 分享单张图片
shareWithSystem({
imageUrl: "/static/test-image/logo.png",
type: 'image'
})
// 分享多张图片
shareWithSystem({
imagePaths: ["/static/img1.png", "/static/img2.png"],
type: 'image'
})
// 分享视频
shareWithSystem({
videoPaths: ["/static/video.mp4"],
type: 'video'
})
// 分享音频
shareWithSystem({
audioPaths: ["/static/audio.mp3"],
type: 'audio'
})
// 分享文件
shareWithSystem({
filePaths: ["/static/file.zip"],
type: 'file'
})
// 同时分享链接、文本和图片
shareWithSystem({
summary: "欢迎使用uni-app",
href: "https://uniapp.dcloud.io",
imagePaths: ["/static/image.png"],
type: 'image'
})
参数说明
| 参数 |
类型 |
必填 |
说明 |
| type |
string |
否 |
分享类型,默认为 text。可选值:text、image、video、audio、file |
| summary |
string |
否 |
分享的文字内容 |
| href |
string |
否 |
分享链接,必须以 http:// 或 https:// 开头 |
| imageUrl |
string |
否 |
分享单个图片,仅支持本地路径 |
| imagePaths |
Array\<string> |
否 |
分享多张图片,仅支持本地路径 |
| videoPaths |
Array\<string> |
否 |
分享视频,仅支持本地路径 |
| audioPaths |
Array\<string> |
否 |
分享音频,仅支持本地路径 |
| filePaths |
Array\<string> |
否 |
分享文件,仅支持本地路径 |
| success |
Function |
否 |
成功回调 |
| fail |
Function |
否 |
失败回调 |
| complete |
Function |
否 |
完成回调 |
错误码
| 错误码 |
说明 |
| 1310600 |
取消分享 |
| 1310601 |
分享内容不可以为空 |
| 1310602 |
系统分享出错 |
| 1310603 |
图片路径无效 |
| 1310604 |
无效的链接 |
| 1310605 |
video 路径无效 |
| 1310606 |
file 文件不存在 |
| 1310607 |
audio 路径无效 |