午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

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

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

};

相關文章:
主站蜘蛛池模板: 亚洲一区二区精品在线 | 国产高清91 | 欧美日一本 | 污视频网站免费看 | 欧美国产第一页 | 潘金莲一级淫片aaaaaa播放1 | 亚洲欧美日韩国产一区 | 国产精品乱码一区二三区小蝌蚪 | 最新日本中文字幕 | 新国产视频 | www.xxx国产| 色婷婷粉嫩av| 色天天综合 | 成人精品福利视频 | www国产91| 国产中文字幕一区二区 | 欧洲a级片 | 超碰777| 黄色片在线观看视频 | 免费在线中文字幕 | 精品亚洲在线 | 日本黄色一级网站 | 日韩视频专区 | 自拍偷拍第五页 | 色狠狠一区二区三区 | 91精品国产91久久久久久黑人 | 亚洲精品久久久久久久久久久 | 婷婷激情六月 | 欧美综合一区二区 | xxxx黄色片| 好吊视频一区二区三区四区 | 国产精品一区二区不卡 | 丁香色综合 | 激情网站在线 | 久操视频免费在线观看 | 日本韩国欧美在线 | 亚洲丁香网 | av在线超碰| 日韩综合一区二区 | 黄色成年视频 | 久久久久久久福利 |