【问题标题】:Angular 2 error : SyntaxError: Unexpected token <Angular 2 错误:SyntaxError: Unexpected token <
【发布时间】:2016-07-22 00:33:49
【问题描述】:

我知道这个问题被问了大约 100 次,但我收到了这个错误。请检查屏幕截图。

错误:SyntaxError: Unexpected token http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:2:14) 在评估 (http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:13:4) 评估http://localhost:3000/moment 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-inner.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-popup.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker.js 评估http://localhost:3000/node_modules/ng2-bootstrap/ng2-bootstrap.js 加载http://localhost:3000/app/main.js时出错

我遵循了修复系统配置的解决方案

System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          'ng2-bootstrap': {
            defaultExtension: 'js'
          }
        },
        map: {
          // place for ng2 modules mapping
          'ng2-bootstrap': 'node_modules/ng2-bootstrap'
        }
});

但是在这个解决方案之后我得到了错误并且页面没有加载......

任何知道要遵循的步骤的人请告诉我。

【问题讨论】:

  • I know this question is asked about 100 times ....
  • 请发布您的 datepickerformatter 代码

标签: angular ng2-bootstrap


【解决方案1】:

事实上,ng2-boostrap 提供了一个捆绑文件。只需将其添加到脚本元素中,并删除 SystemJS 的相关配置即可:

<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.js"></script>

System.config({
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      },
      'ng2-bootstrap': {
        defaultExtension: 'js'
      }
    },
    map: {
      // place for ng2 modules mapping
      'ng2-bootstrap': 'node_modules/ng2-bootstrap'
    }
});

这可以在使用 npm 安装 ng2-bootstrap 后完成。

【讨论】:

    猜你喜欢
    • 2016-10-01
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 2015-04-21
    • 2016-11-27
    • 2022-01-22
    • 2015-05-07
    • 2017-06-07
    相关资源
    最近更新 更多