Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

weex xxx.vue 命令只有加载index.vue文件才正常 #4

Open
phoenixsky opened this issue Nov 9, 2017 · 0 comments
Open

weex xxx.vue 命令只有加载index.vue文件才正常 #4

phoenixsky opened this issue Nov 9, 2017 · 0 comments

Comments

@phoenixsky
Copy link

在用weex init命令初始化的project中.在src/下写了几个vue文件,想通过weex your_best.vue 命令,看看页面效果,多次运行无果,调查后发现,实际安装的weex-preiviewer的
\vue-template\template\assets\weex-init.js文件,github上的代码,与实际安装的的weex-previewer([email protected])不同,但是这个版本已经是我能更新的最新版了.

1.3.13-beta.9代码:

(function () {
  function getUrlParam (key, url) {
    var reg = new RegExp('[?|&]' + key + '=([^&]+)')
    var match = location.search.match(reg)
    return match && match[1]
  };
  var page = getUrlParam('page') || 'index.js';
  var bundle = document.createElement('script')
  // only for web
  bundle.src = page
  document.body.appendChild(bundle)
})();

以上代码导致.我不管weex哪一个.vue文件,浏览器离加载的永远都是index.vue;
将github上的文件copy到本地后还是有问题,追踪后,发现在最后有个if判断,导致还是不能顺利加载别的vue文件.将其注销后,直接返回else中内容.可行.,不知道这里的代码是什么情况

  // 不知道这个if的作用是什么? 
  if (window.weex && window.weex.init ) {
    window.weex.init({
      appId: location.href,
      source: page,
      loader: 'xhr',
      rootId: 'weex'
    });
  } else {
    var bundle = document.createElement('script');
    bundle.src = page;
    document.body.appendChild(bundle);
  }

另外,通过weex xxx.vue命令在mac下可正常,修改后保存,热更新.在win下怎么就不好使呢?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant