npm i --save nativescript-cscreenshot
- 版本:1.2.1
- GitHub: https://github.com/Javierpal/nativescript-cscreenshot
- NPM: https://npmjs.net.cn/package/nativescript-cscreenshot
- 下载
- 昨天: 26
- 上周: 49
- 上个月: 320
Nativescript Cscreenshot :camera
此插件是为了让您轻松截图视图并按需存储。
此插件基于 enchev 的 NativeScript Screenshot nativescript-screenshot,但进行了更新以提高稳定性和与 angular、vue 和 react 的兼容性(仍在测试 vue 和 react)
现在在 Nativescript 8 上运行
重要:由于某种原因,我无法测试 iOS 版本,因为这个问题 Github,如果您可以测试并在此问题页面报告,我将不胜感激。
安装
使用安装命令
tns plugin add nativescript-cscreenshot
用法
只需将插件导入到您的项目中,并像这样使用它
使用 TypeScript
import { Cscreenshot } from 'nativescript-cscreenshot';
import { ImageSource } from "tns-core-modules/image-source";
// then in your take a screenshot method
let screen = new Cscreenshot();
// Using vanilla Nativescript
let view = page.getViewById('main');
// Using Angular Nativescript
@ViewChild("main", { static: true }) main: ElementRef;
let view = this.view.nativeElement;
// Using Vue Nativescript
let view = this.$refs.main.nativeView;
screen.take(view, (image: ImageSource)=>{
// Do whatever you want with the returned source image
});
并在您的模板中
<!-- Assign the reference name depending on the framework -->
<!-- 'id=""' for vanilla nativescript -->
<!-- '#main' for angular nativescript -->
<!-- 'ref="main"' for Vue nativescript -->
<GridLayout id="main" #main ref="main">
<!-- Content of your app here -->
</GridLayout>
许可协议
Apache 许可协议版本 2.0,2004 年 1 月