npm i --save nativescript-url-share
- 版本:1.6.3
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-url-share
- 下载
- 昨日: 0
- 上周: 0
- 上个月: 0
NativeScript Url Share 插件
由 https://github.com/tjvantoll/nativescript-social-share 衍生。
一个 NativeScript 插件,用于在 Android 和 iOS 上使用本地社交分享小部件。目前此模块支持图片和文本分享。
安装
从项目的根目录运行以下命令
$ tns plugin add nativescript-url-share
此命令将自动安装必要的文件,并在项目的 package.json
文件中将 nativescript-url-share 作为依赖项存储。
用法
要使用社交分享模块,您必须首先 require()
它。在您 require()
模块后,您将能够访问其 API。
// ------------ JavaScript ------------------
var UrlShare = require("nativescript-url-share");
// ------------- TypeScript ------------------
import * as UrlShare from "nativescript-url-share";
API
shareUrl(String url, String text, [optional] String subject)
shareUrl()
方法接受一个 URL 和一个字符串。
UrlShare.shareUrl("https://www.nativescript.org/", "Home of NativeScript");
您可以选择向 shareUrl()
传递第二个参数以在 Android 上配置主题
UrlShare.shareUrl("https://www.nativescript.org/", "Home of NativeScript", "How would you like to share this url?");
教程
在移动应用程序中设置社交分享需要额外帮助?请查看以下资源