::: sourceCode ## uni.shareWithSystem(options) @sharewithsystem > issues: https://issues.dcloud.net.cn/?mid=api.share.shareWithSystem > 源码: https://github.com/dcloudio/uni-app/tree/uni-app-x-alpha/src/uni_modules/uni-shareWithSystem ::: 使用系统分享。 系统分享不同于SDK分享。不需要配置三方SDK的key信息。手机上安装的、可接受分享的应用都会出现在列表中。 ### shareWithSystem 兼容性 ### 参数 | 名称 | 类型 | 必填 | 兼容性 | | :- | :- | :- | :-: | | options | **ShareWithSystemOptions** | 是 | Web: x | #### options 的属性描述 | 名称 | 类型 | 必备 | 兼容性 | 描述 | | :- | :- | :- | :-: | :- | | type | string | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享类型,默认为text。 | | summary | string | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享的文字内容 | | href | string | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享链接 | | imageUrl | string | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享单个图片,仅支持本地路径 | | imagePaths | Array<string> | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享图片,仅支持本地路径 | | videoPaths | Array<string> | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享video,仅支持本地路径 | | audioPaths | Array<string> | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享audio,仅支持本地路径 | | filePaths | Array<string> | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | 分享文件,仅支持本地路径 | | success | (res: ShareWithSystemSuccess) => void | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | uni.shareWithSystem成功回调函数定义 | | fail | (res: [ShareWithSystemFail](#sharewithsystemfail-values)) => void | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | uni.shareWithSystem失败回调函数定义 | | complete | (res: any) => void | 否 | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | uni.shareWithSystem完成回调函数定义 | ##### type 的属性描述 | 合法值 | 兼容性 | 描述 | | :- | :-: | :- | | "text" | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | text类型 | | "image" | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | image类型 | | "video" | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | video类型 | | "audio" | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | audio类型 | | "file" | Web: x; Android: 4.33; iOS: 4.33; HarmonyOS: 4.61 | file类型 | #### ShareWithSystemFail 的属性值 @sharewithsystemfail-values | 名称 | 类型 | 必备 | 兼容性 | 描述 | | :- | :- | :- | :-: | :- | | errCode | number | 是 | Web: x | 错误码 | | errSubject | string | 是 | Web: x | 统一错误主题(模块)名称 | | data | any | 否 | Web: x | 错误信息中包含的数据 | | cause | [Error](/err-spec.md#unierror) | 否 | | 源错误信息,可以包含多个错误,详见SourceError | | errMsg | string | 是 | Web: x | | #### errCode 的属性描述 | 合法值 | 兼容性 | 描述 | | :- | :-: | :- | | 1310600 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: x | 取消分享 | | 1310601 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: x | 分享内容不可以为空 | | 1310602 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: x | 已经成功调用系统分享接口,系统分享出错 | | 1310603 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: 4.61 | 图片路径无效 | | 1310604 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: x | 无效的链接 | | 1310605 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: 4.61 | video 路径无效 | | 1310606 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: 4.61 | file 文件不存在 | | 1310607 | Web: x; Android: 4.33; iOS(VDOM): 4.33; iOS(Vapor): 5.08; HarmonyOS: 4.61 | audio 路径无效 | ### 示例 示例为[hello uni-app x alpha分支](https://gitcode.com/dcloud/hello-uni-app-x/blob/prod_alpha/pages/API/share-with-system/share-with-system.uvue),与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例[另见](https://gitcode.com/dcloud/hello-uni-app-x/blob/master//pages/API/share-with-system/share-with-system.uvue) > > 该 API 不支持 Web,请运行 hello uni-app x 到 App 平台体验 ::: preview > appRedirect https://hellouniappx.dcloud.net.cn/appredirect.html?path=pages/API/share-with-system/share-with-system ```uvue ``` ::: ## 通用类型 ### GeneralCallbackResult @generalcallbackresult-values | 名称 | 类型 | 必备 | 描述 | | :- | :- | :- | :- | | errMsg | string | 是 | 错误信息 | ## 注意 系统分享和微信SDK分享在Android上有些差异 1. 系统分享单张图片可以进朋友圈,多张图片进朋友圈只能使用微信SDK。 2. Android的系统分享,分享链接到微信只能以文本方式分享,如需方条链接需使用微信SDK,即[uni.share](./share.md)。iOS的系统分享可以分享方条链接。 3. Android的系统分享同时分享链接和图片到微信最终只能分享图片。而iOS的系统分享同时分享链接和图片,会把图片作为链接的题图。