Cordova常用操作

安装

sudo npm install -g cordova
cordova create AppName
cordova platform add browser
cordova run browser
cordova platform add android --save
cordova platform ls
cordova requirements

编译

cordova build android
cordova build android -release
cordova emulate android

配置XML

vi config.xml
<content src="http://IP:PORT/index.html" />
<allow-navigation href="http:///" />
<preference name="Fullscreen" value="true" />

签名

keytool -genkey -v -keystore release-key.keystore -alias cordova-demo -keyalg RSA -keysize 2048 -validity 10000
vi build.json

{
  "android": {
    "release": {
      "keystore": "release-key.keystore",
      "alias": "cordova-demo",
      "storePassword": "password",
      "password": "password"
    }
  }
}

禁用缓存

import android.webkit.WebSettings;
import android.webkit.WebView;
@Override
protected void onResume() {
    super.onResume();
    // Disable caching ..
    WebView wv = (WebView) appView.getEngine().getView();
    WebSettings ws = wv.getSettings();
    ws.setAppCacheEnabled(false);
    ws.setCacheMode(WebSettings.LOAD_NO_CACHE);
    loadUrl(launchUrl); // launchUrl is the default url specified in Config.xml
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容