亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

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

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

瀏覽:196日期: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;

};

相關文章:
主站蜘蛛池模板: 久久精品视频在线观看榴莲视频 | 国产真实乱子伦精品视手机观看 | 欧美人成a视频www | 国产成人黄网址在线视频 | 成人免费视频网 | 欧美日韩美女 | 欧美亚洲国产成人精品 | 国产精品高清一区二区 | 精品久久久久久久久久香蕉 | 亚洲伊人久久综合影院2021 | 美国毛片视频 | 亚洲韩国欧美一区二区三区 | 亚洲色吧| 中文偷拍视频在线观看 | 日韩美女大全视频在线 | 国产成人精品午夜 | 欧美一级久久久久久久大片 | 办公室紧身裙丝袜av在线 | 国产精品2020观看久久 | 日韩欧美在线精品 | 牛牛本精品99久久精品88m | 久久毛片网站 | 69成人做爰视频69 | 一二三中文乱码亚洲乱码 | 日韩成人精品日本亚洲 | 91精品国产91热久久p | 美女视频黄a视频美女大全 美女视频黄a视频免费全程 | 亚洲高清毛片 | 国产精品亚洲国产三区 | 亚洲第3页 | 亚洲精品色综合色在线观看 | 爆操巨乳美女 | 日本在线免费观看视频 | 免费观看情趣v视频网站 | 精品在线观看国产 | 2022国内精品免费福利视频 | 免费久久精品 | 成人亚洲精品一区二区 | 亚洲线精品久久一区二区三区 | 狼伊千合综网中文 | 狠狠做久久深爱婷婷97动漫 |