從伺服器上擷取js檔案缺失很友善 但是沒法解決跳轉渲染的時間
而且ios端貌似稽核不過
最後統一一下将伺服器端的js包在引導頁面下載下傳到sd卡
然後解壓
最開始我直接用的weex端加載本地assets檔案下的方法 loadasserts加上我的路徑一直沒法顯示
總是覺得是我的路徑沒有寫對 各種改還是沒法顯示
後來發現weex的這個Loadassets沒法加載sd卡裡的檔案
這個破問題浪費了我一天的時間 狗尴尬的 寫出來大家少走彎路
public static String loadAssetttt(String path, Context context) {
if (context == null || TextUtils.isEmpty(path)) {
return null;
}
InputStream inputStream = null;
BufferedReader bufferedReader = null;
try {
File f = new File(path);
inputStream = new FileInputStream(f);
// inputStream = context.getAssets().open(path);
StringBuilder builder = new StringBuilder(inputStream.available() + 10);
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
char[] data = new char[4096];
int len = -1;
while ((len = bufferedReader.read(data)) > 0) {
builder.append(data, 0, len);
}
return builder.toString();
} catch (IOException e) {
e.printStackTrace();
WXLogUtils.e("", e);
} finally {
try {
if (bufferedReader != null)
bufferedReader.close();
} catch (IOException e) {
WXLogUtils.e("WXFileUtils loadAssetttt: ", e);
}
try {
if (inputStream != null)
inputStream.close();
} catch (IOException e) {
WXLogUtils.e("WXFileUtils loadAssetttt: ", e);
}
}
return "";
}
相當于在本地加載了 也能實作動态的更新