plus使用注意事項 plusready react


plus plusready 使用注意事項 react

零、前言

這段時間寫HTML5+項目時 遇到一個plusReady的問題
運用plus時一定要先plusReady

一、代碼展示

一般plusready在componentDidmount中就執行

//在掛載之后進行  很重要  一定要有
componentDidMount(){
   if(window.plus){//當有plus時,直接plusPredy
     this.plusReady();
   }else{//當沒有plus時,要先創造plusready事件
     document.addEventListener('plusready',this.plusReady,false);
   }
 }

 //plusReady函數  在這里才能調用plus api
 plusReady=()=>{
   // 在這里調用plus api
     this.creatBarCode()
   
 }
 // 創建barcode控件  使用plus api的地方
 creatBarCode() {
   if (!barcode) {
     barcode = plus.barcode.create('barcode', [plus.barcode.QR], {
       top:'100px',
       left:'0px',
       width: '100%',
       height: '500px',
       position: 'static'
     });
     barcode.onmarked = function (type, result) {
       alert('掃描結果:'+result)
     };
     plus.webview.currentWebview().append(barcode);
   }
   barcode.start();
 }

二、總結需要plusready的h5+API

這里我只記錄我知道的,不知道的就沒寫啦

1.緩存 plus.storage

存:一定要 取:一定要 清空:不清楚

2.文件 plus.io

存:好像不用 取:一定要的

3.掃碼 plus.barcode

一定要

4.相冊 plus.gallery

好像不用

5.按鍵 plus.key

應該要吧

6.原生界面 plus.NativeUI

不清楚

7.頁面:plus.webview

好像不用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM