av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

關于android 集成weex 加載js 時報ReferenceError: window is not defined

瀏覽:202日期:2024-08-17 16:08:30

問題描述

關于android 集成weex 加載js 時報ReferenceError: window is not defined如題將.we 文件npm run build 后將js拷貝到android asset文件下面,按照官方的集成步驟運行android studio 頁面空白 控制臺報 04-11 11:48:50.946 3321-3345/com.weex.sample E/jsengine: ReportException :undefined:2212: ReferenceError: window is not defined 04-11 11:48:50.949 3321-3345/com.weex.sample E/jsengine: ReportException : ReferenceError: window is not defined

at Object.exports.getBaseUrl (eval at Cn ((weex):2:4300), <anonymous>:2212:21) at Yt.created (eval at Cn ((weex):2:4300), <anonymous>:104:26) at (weex):1:27665 at Array.forEach (native) at Yt.zt [as $emit] ((weex):1:27643) at new Yt ((weex):1:29107) at ln ((weex):2:98) at a ((weex):2:2870) at Object.module.exports.type (eval at Cn ((weex):2:4300), <anonymous>:67:2) at __webpack_require__ (eval at Cn ((weex):2:4300), <anonymous>:26:30)

04-11 11:48:50.950 3321-3345/com.weex.sample E/weex: reportJSException >>>> instanceId:2, exception function:createInstance, exception:ReferenceError: window is not defined

問題解答

回答1:

在原生層面window對象不支持

回答2:

找到答案了 是在頁面跳轉時獲取頁面uri階段出問題了 使用了window.location.host andorid 這邊不認識這個window

exports.getBaseUrl = function (bundleUrl, isnav) {

bundleUrl = new String(bundleUrl);var nativeBase;var isAndroidAssets = bundleUrl.indexOf(’file://assets/’) >= 0;var isiOSAssets = bundleUrl.indexOf(’file:///’) >= 0 && bundleUrl.indexOf(’WeexDemo.app’) > 0;if (isAndroidAssets) { nativeBase = ’file://assets/dist/’;}else if (isiOSAssets) { nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf(’/’) + 1);}else { // var host = window.location.host; 這個在瀏覽器中可以用 var host; var matches = ///([^/]+?)//.exec(bundleUrl); if (matches && matches.length >= 2) {host = matches[1]; } // alert('er:::'+host); //此處需注意一下,tabbar 用的直接是jsbundle 的路徑,但是navigator是直接跳轉到新頁面上的. // if (typeof window === ’object’) { // nativeBase = isnav ? ’http://’ + host + ’/index.html?page=./dist/’ : ’/dist/’; // } else { // nativeBase = ’http://’ + host + ’/dist/’; // }}// alert('nativeBase: '+nativeBase);nativeBase='http://'+host+'/dist/';return nativeBase;

};

相關文章:
主站蜘蛛池模板: 欧美一级做性受免费大片免费 | 精品视频国产 | 国产性猛交96 | 欧美日韩在线看 | 久久九九国产 | 九九在线观看高清免费 | 91五月天 | 奇米网888| 毛片aaa| 日韩免费视频 | 亚洲天堂第一页 | 在线观看国产小视频 | www一级片 | av一区二区三区 | 久久视频在线免费观看 | 999精品视频 | 综合99 | 国产亚洲天堂 | 99一区二区三区 | 精品网站999www | 日韩黄色在线视频 | 成年人视频网站 | 一区二区精品在线 | 国产成人亚洲精品自产在线 | 草少妇| 长河落日电视连续剧免费观看 | 久久99精品国产麻豆91樱花 | 六月丁香激情 | 国产三级视频 | 国产精品理论片 | 日韩在线小视频 | 欧美18免费视频 | 999精品视频| 午夜网| www.四虎.com| 午夜在线视频观看 | 加勒比一区二区三区 | 亚洲国产中文字幕 | 可以免费看黄的网站 | av福利在线观看 | h网站在线观看 |