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 不能使用。

posted @ 2020-01-03 14:25  Tommy_marc  阅读(1346)  评论(0编辑  收藏  举报