Javascript ES6—导入es5文件

Javascript ES6—导入es5文件,javascript,angularjs,twitter-bootstrap,ecmascript-6,gocardless,Javascript,Angularjs,Twitter Bootstrap,Ecmascript 6,Gocardless,我尝试使用这个()作为起点,然后包含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-compil

我尝试使用这个()作为起点,然后包含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'

  }
});
  • 尝试
    导出
    而不是
    导出
  • System.config({
    元:{
    //...
    'components/bootstrap/dist/js':{format:'global',exports:'bootstrap'}
    }
    //...
    });
    
  • 当您写入
    {format:'global',导出:'bootstrap'}
    时,您试图获取全局
    引导变量。但这种情况并不存在。所以我认为你们必须删除元线并修复映射。结果必须如下所示:
  • System.config({
    元:{
    //...
    'components/path/to/jquery':{format:'global',exports:'jquery'},
    'components/bootstrap/dist/js/bootstrap':{deps:['jquery']}
    }
    地图:{
    //...
    “jquery”:“components/path/to/jquery”,
    'bootstrap js':'components/bootstrap/dist/js/bootstrap'
    }
    });
    
    似乎仍然不起作用,我甚至试着把它放在正确的路径中,比如:/components/bootstrap/dist/js/bootstrap.min.js-->@geoHeil我想我理解你的问题。当您写入
    {format:'global',导出:'bootstrap'}
    时,您试图获取全局
    引导变量。但事实并非如此,这似乎是正确的:现在我得到了:潜在的未处理拒绝[2]错误评估未捕获错误:Bootstrap的JavaScript需要jQuery(警告:未使用错误)@geoHeil我认为您必须将jQuery添加到包中,并指定对Bootstrap的依赖性。所以我更新了答案。我希望这会有所帮助。