简单的Angular 2项目失败'意外的保留字'

问题描述 投票:0回答:1

我正在尝试基于ng2do项目创建一个简单的Angular2项目。我正在使用快速入门,我有以下代码......

<script src="js/quickstart/dist/es6-shim.js"></script>

....
import {Component, Template, bootstrap, Foreach} from 'js/quickstart/angular2/angular2';

这给了我以下错误......

Uncaught SyntaxError: Unexpected reserved word

我错过了什么?

angular ecmascript-6
1个回答
0
投票

不知道这是否有帮助我整天都有这个问题意识到这是因为我用脚本引用开始我的代码

<script src="app.js">
</script>

而不是使用

<script>
   System.import('app');
</script>

希望这有助于在tsconfig中使用它

{
    "version": "1.5.0-beta",
    "compilerOptions": {
        "target": "es6",
        "module": "amd",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "preserveConstEnums": true,
        "suppressImplicitAnyIndexErrors": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
    },
    "filesGlob": [
        "./**/*.ts",
        "!./node_modules/**/*.ts"
    ],
    "files": [
        "./main.ts",
        "./show-properties.ts",
        "./typings/angular2/angular2.d.ts",
        "./typings/es6-promise/es6-promise.d.ts",
        "./typings/rx/rx-lite.d.ts",
        "./typings/rx/rx.d.ts"
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.