ionic4 拍照,相册选择相片

2019-08-05  本文已影响0人  Lemonsu2018

ionic4 调用相机拍照,并回显图片功能实现

1.安装Camera插件

    ionic cordova plugin add cordova-plugin-camera

    npm install @ionic-native/camera

2.在app.module.ts中引入Camera

    import { Camera } from '@ionic-native/camera/ngx';

    providers: [

        ...,

        Camera,

        ...

    ],

3.在需要使用的页面引入

    import { Camera, CameraOptions } from '@ionic-native/camera/ngx';

    constructor(private camera: Camera) {}

4.调用getPicture调用相机,通过webview插件处理回调数据,显示到页面,<img [src]="userLogo">

ionic4 调用系统相册,并回显图片功能实现

1.安装ImagePicker插件

    ionic cordova plugin add cordova-plugin-telerik-imagepicker

    npm install @ionic-native/image-picker

2.在app.module.ts中引入ImagePicker

    import { ImagePicker } from '@ionic-native/image-picker/ngx';

    providers: [

        ...,

        ImagePicker,

        ...

    ],

3.在需要使用的页面引入

    import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker/ngx';

    constructor(private imagePicker: ImagePicker) {}

4.调用getPicture调用相册,通过webview插件处理回调数据,显示到页面,<img [src]="userLogo">

上一篇 下一篇

猜你喜欢

热点阅读