我尝试以此(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'

  }
});

最佳答案

  • 在此处尝试exports而不是export:

  • System.config({
        meta: {
        //...
            'components/bootstrap/dist/js':{ format: 'global', exports: 'bootstrap'}
        }
        //...
    });
    
  • 当您编写{ format: 'global', exports: 'bootstrap'}时,您试图获取全局bootstrap变量。但是这样不存在。因此,我认为您必须删除中继线并修复 map 。结果必须类似于:

  • 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'
        }
    });
    

    09-25 16:57
    查看更多