美文网首页
weex笔记(2)weex使用navigator跳转到bundl

weex笔记(2)weex使用navigator跳转到bundl

作者: FateOfKing | 来源:发表于2018-11-28 16:39 被阅读0次

路径获取:官方地址

exports.getBaseURL = function (vm) {
  var bundleUrl = weex.config.bundleUrl;
  var nativeBase;
  var isAndroidAssets = bundleUrl.indexOf('your_current_IP') >= 0 || bundleUrl.indexOf('file://assets/')>=0;
  var isiOSAssets = bundleUrl.indexOf('file:///') >= 0 && bundleUrl.indexOf('WeexDemo.app') > 0;
  if (isAndroidAssets) {
    nativeBase = 'file://assets/';
  }
  else if (isiOSAssets) {
    // file:///var/mobile/Containers/Bundle/Application/{id}/WeexDemo.app/
    // file:///Users/{user}/Library/Developer/CoreSimulator/Devices/{id}/data/Containers/Bundle/Application/{id}/WeexDemo.app/
    nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1);
  }
  else {
    var host = 'localhost:12580';
    var matches = /\/\/([^\/]+?)\//.exec(weex.config.bundleUrl);
    if (matches && matches.length >= 2) {
      host = matches[1];
    }
    nativeBase = 'http://' + host + '/' + vm.dir + '/build/';
  }
  var h5Base = './index.html?page=./' + vm.dir + '/build/';
  // in Native
  var base = nativeBase;
  if (typeof window === 'object') {
    // in Browser or WebView
    base = h5Base;
  }
  return base
}

声明navigator

    var navigator = weex.requireModule('navigator');

使用navigator

navigator.push({
                    url:baseurl+'login.js'
                }, event =>{

                })

相关文章

网友评论

      本文标题:weex笔记(2)weex使用navigator跳转到bundl

      本文链接:https://www.haomeiwen.com/subject/szkzqqtx.html