angular2-找不到浏览器,corejs



根据这个线程,我包括ng2-bs3-modal,用于在angular2中创建模态。由于ng2-bs3-modal和它加载的js文件(如modal.js、modal-header.js)默认情况下不使用.js作为扩展名,因此我必须使用deafultJsExtension:true来实现这一点。为了防止根据同一线程出现角度错误(angular正在浏览器中再次加载其模块),我在加载systemjs后直接包含了system.config,而不是在加载angularjs后写入它,

 <script src="node_modules/es6-shim/es6-shim.min.js">
    </script>
    <script src="node_modules/systemjs/dist/system-polyfills.js">
    </script>
    <script src="node_modules/systemjs/dist/system.src.js">
    </script>
    <!-- 2. Configure SystemJS -->
    <script>
        System.config({
          defaultJSExtensions: true,
          packages: {
            angular: { defaultExtension: false },
            app: {
              format: 'register',
              defaultExtension: 'js'
            },
          },
          map: {
              'ng2-bs3-modal': 'node_modules/ng2-bs3-modal',
          }
        });
        System.import('node_modules/jquery/dist/jquery.min.js')
        System.import('node_modules/bootstrap/dist/js/bootstrap.min.js');
        System.import('app/js/main')
        .then(null, console.error.bind(console));
    </script>
    <script src="node_modules/angular2/bundles/angular2-polyfills.js">
    </script>
    <script src="node_modules/rxjs/bundles/Rx.js">
    </script>
    <script src="node_modules/angular2/bundles/angular2.dev.js">
    </script>

现在,有时它工作得很好,有时它说browser.js,core.js找不到,还有system.js错误

(控制台上显示GEThttp://localhost:3000/angular2/core.js404(找不到)--system.src.js:1068断言失败:正在加载或已加载--system.src.js:291

有人能认出这个吗感谢

好的,所以从错误中可以很明显地得到答案,我还必须为angular2写一个映射::-

map: {
       'ng2-bs3-modal': 'node_modules/ng2-bs3-modal',
       'angular2': 'node_modules/angular2'
     }

也许这与加载文件和polyfill脚本的顺序有关,但这个顺序是从我在互联网上读到的源代码中获取的,没有任何地方写过我们可能会遇到这样的错误。

每个人都在发生这种事,对吧?还是只有我

最新更新