本项目是用vue嵌套原生混合开发的app,使用H5+api的input标签调用摄像头,在浏览器上面调用摄像头是好的,使用hbuilder打包之后就不能正常调用摄像头

<input type="file" class="capture"  capture="camera" @click="clickHandle" >

  解决办法:给input绑定点击事件在methods里调用这个clickHandle这个方法利用plus.camera实现iOS的相机调用

 clickHandle() {
         const cmr = window.plus.camera.getCamera();
         cmr.captureImage((p) => {
           window.plus.io.resolveLocalFileSystemURL(p, (entry) => {
             window.compressImage(entry.toLocalURL(), entry.name);
           }, (e) => {
             window.plus.navtiveUI.toast('读取拍照文件错误:' + e.message);
           });
         }, (e) => {
        console.log(e);
         }, { filter: 'image' });
      },

  

相关文章:

  • 2021-12-13
  • 2021-11-28
  • 2022-12-23
  • 2021-07-26
  • 2021-09-19
  • 2022-12-23
  • 2021-05-02
猜你喜欢
  • 2021-06-13
  • 2021-11-28
  • 2021-07-16
  • 2022-01-09
  • 2021-10-24
  • 2022-03-05
  • 2022-12-23
相关资源
相似解决方案