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

相關文章
相關標籤/搜索