就例如简单一个按钮,点击跳转下一个js。我的baseUrl不知道怎么获取,网上说的
var bundleUrl = this.$getConfig().bundleUrl;
bundleUrl = new String(bundleUrl);
var nativeBase;
var isAndroidAssets = bundleUrl.indexOf('file://assets/') >= 0;
var isiOSAssets = bundleUrl.indexOf('file:///') >= 0 && bundleUrl.indexOf('myAPP.app') > 0;
if (isAndroidAssets) {
nativeBase = 'file://assets/';
}
else if (isiOSAssets) {
nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1);
}
else {
var host = 'localhost:12500';
var matches = /\/\/([^\/]+?)\//.exec(this.$getConfig().bundleUrl);
if (matches && matches.length >= 2) {
host = matches[1];
}
nativeBase = 'http://' + host + '/' + this.dir + '/dist/';
}
var h5Base = './index.html?page=./' + this.dir + '/dist/';
//Native端
var base = nativeBase;
//H5端
if (typeof window === 'object') {
base = h5Base;
}
this.baseURL = base;
获取不到
jump: function() {
console.log('will jump')
navigator.push({
url: this.baseUrl+'foo.js',
animated: "true"
}, event => {
modal.toast({ message: 'callback: ' + event })
})
},
https://github.com/apache/inc...
请参考这个方法
这个方法有缺陷的,你是 weex run web 还是weex src命令,如果是weex run web,需要将var h5Base = './index.html?page=./' + this.dir + '/dist/';改成 var h5Base = './weex.html?page=dist/';俺正很多坑,注意一下吧。