我刚刚设置了我的第一个离子2应用程序(我已经相当广泛地使用了离子1).我正在尝试使用离子原生相机预览插件.
设置很简单:
npm install -g ionic cordova
ionic start timesnap --v2
ionic platform add android
ionic platform add ios
ionic plugin add cordova-plugin-camera-preview --save
Run Code Online (Sandbox Code Playgroud)
然后我将示例代码复制并粘贴到about页面中:
import { CameraPreview, CameraPreviewRect } from 'ionic-native';
// camera options (Size and location)
let cameraRect: CameraPreviewRect = {
x: 100,
y: 100,
width: 200,
height: 200
};
// start camera
CameraPreview.startCamera(
cameraRect, // position and size of preview
'front', // default camera
true, // tap to take picture
false, // disable drag
true, …Run Code Online (Sandbox Code Playgroud)