美文网首页
ionic4 拍照,相册选择相片

ionic4 拍照,相册选择相片

作者: Lemonsu2018 | 来源:发表于2019-08-05 15:02 被阅读0次

    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">

    相关文章

      网友评论

          本文标题:ionic4 拍照,相册选择相片

          本文链接:https://www.haomeiwen.com/subject/nglmdctx.html