ES6 - 导入es5文件

时间:2015-01-20 15:25:35

标签: javascript angularjs twitter-bootstrap ecmascript-6 gocardless

我尝试使用此(https://github.com/gocardless/es6-angularjs/blob/master/README.md)作为起点,然后包含bootstrap javascript代码。为了打开模态

但唯一发生的事情是:

Potentially unhandled rejection [3] Error loading "components/bootstrap/dist/js" at http://localhost:3010/components/bootstrap/dist/js.js
Error loading "components/bootstrap/dist/js" from "app-compiled/bootstrap" at http://localhost:3010/app-compiled/bootstrap.js
Not Found: http://localhost:3010/components/bootstrap/dist/js.js (WARNING: non-Error used)

我把它添加到main.js:

import 'bootstrap-js';
//TODO please explain to me why not working

和loader.config.js文件:

System.config({
  meta: {

    ...,
    'components/bootstrap/dist/js':{ format: 'global', export: 'bootstrap'}


  },
  map: {

    ....,
    'bootstrap-js': 'components/bootstrap/dist/js'

  }
});

1 个答案:

答案 0 :(得分:1)

  1. 在此处尝试exports而不是export
  2. System.config({
        meta: {
        //...
            'components/bootstrap/dist/js':{ format: 'global', exports: 'bootstrap'}
        }
        //...
    });
    
    1. 当你写{ format: 'global', exports: 'bootstrap'}时,你试图获得全局bootstrap变量。但这种情况并不存在。所以我认为你必须删除元线和修复地图。结果必须如下所示:
    2. System.config({
          meta: {
              //...
              'components/path/to/jquery': { format: 'global', exports: 'jQuery' },
              'components/bootstrap/dist/js/bootstrap': { deps: ['jquery'] }
          }
          map: {
              //...
              'jquery': 'components/path/to/jquery',
              'bootstrap-js': 'components/bootstrap/dist/js/bootstrap'
          }
      });
      
相关问题