vue 开发系列(五) 调用原生API

概要

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

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

实现

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

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

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

好比拍照:ide

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});
          }

plus 就是H5+ 的接口调用。ui

 

注意事项

咱们在使用这些接口的时候,须要将系统打包成app,不然plus 不能使用。this

相关文章
相关标签/搜索