当前位置:网站首页>Mobile applications introduce static Cordova according to different platforms

Mobile applications introduce static Cordova according to different platforms

2022-06-21 09:15:00 Tie Hanhan plus

stay index.html The page introduces the following script( Android and ios Of cordova You need to download it yourself and put it in the corresponding path )

<script>
    // ------- Inject cordova, Auto fit androway ios platform 
    (function () {
    
      const agent = navigator.userAgent.toLowerCase();
      console.log(agent);
      let importForCordova;
      if (agent.includes("android")) {
    
        //  If you change the deployment path , It needs to be modified here 
        console.log('android');
        importForCordova = "static/android.cordova.min.js";
      } else if (agent.includes("iphone") || agent.includes("ipad")) {
    
        //  If you change the deployment path , It needs to be modified here 
        console.log('iphone');
        importForCordova = "static/ios.cordova.min.js";
      } else {
    
        console.log("Inject Error,Not android nor iOS.")
        return;
      }
      const cordovaScriptElement = document.createElement('script');
      cordovaScriptElement.setAttribute('type', 'text/javascript');
      cordovaScriptElement.setAttribute('src', importForCordova);
      const head = document.getElementsByTagName('head')[0];
      head.appendChild(cordovaScriptElement);
    })();
    // ------ Inject cordova, Auto fit androway ios platform 
  </script>
原网站

版权声明
本文为[Tie Hanhan plus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221446081658.html