vue开发系列 调用原生API


概要

我们在开发手机端程序的时候了,我们经常需要使用到拍照,二维码的功能.数字天堂公司提供了大量的原生API支持。

http://www.html5plus.org/doc/

实现

1.在hbuilder 选择需要使用的模块

 

2.在组件代码中调用相应的API接口。

比如拍照:

takePhoto(){
            var _self=this;
            var cmr = plus.camera.getCamera();
            var fmt = cmr.supportedImageFormats[0];
            cmr.captureImage( function( path ){
                plus.io.resolveLocalFileSystemURL(path, function(entry) {
                       var tmpPath= entry.toLocalURL();
                       var fileAry=[];
                       fileAry.push(tmpPath);
                       _self.compressImg(fileAry);
                })
              },
              function( error ) {},
              {format:fmt});
          }

注意事项

我们在使用这些接口的时候,需要将系统打包成app,否则plus 不能使用。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM