npm i --save @knotes/nativescript-cscreenshot
- 版本:1.0.0
- GitHub:
- NPM: https://npmjs.net.cn/package/%40knotes%2Fnativescript-cscreenshot
- 下载量
- 昨日: 0
- 上周: 0
- 上月: 0
Nativescript Cscreenshot :camera
此插件旨在让您轻松截图视图,并将其存储为所需格式。
此插件基于 enchev 的 NativeScript Screenshot nativescript-screenshot,但已更新以提高稳定性以及 Angular、Vue 和 React 兼容性(仍在测试 Vue 和 React)
安装
使用安装命令
tns plugin add @enduco/nativescript-cscreenshot
用法
只需将插件导入您的项目中,并按以下方式使用
使用 TypeScript
import { Cscreenshot } from "@enduco/nativescript-cscreenshot";
import { ImageSource } from "@nativescript/core";
// 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
});
and in your template
<!-- 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 License 版本 2.0,2004 年 1 月