更新记录

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 平台。

功能

  • 分享文本
  • 分享链接
  • 分享图片(单张/多张)
  • 分享视频(单个/多个)
  • 分享音频(单个/多个)
  • 分享文件(单个/多个)

平台兼容性

Android iOS
4.33+ 4.33+

使用方法

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 路径无效

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。