我是Angular 2的新手,但對Angular有一些瞭解TypeScript(廣泛使用JavaScript/JQuery但不是TypeScript或Angular 1)。VS 2012中的角度語法錯誤
在探索Angular 2時,我跟着幾篇文章&嘗試閱讀&在Web應用程序中,關注與Visual Studio 2012中Angular 2相關的示例。不知何故,VS不識別Angular語法&在.ts文件中拋出幾個錯誤。下面的示例代碼會引發錯誤。但是VS在HTML中識別TypeScript & Angular 1語法。我試圖找到自己的解決方案,但失敗了。
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '<h1> Hello {{name}}</h1>'
})
export class AppComponent { name = 'Angular'; }
任何幫助將有利於我進一步探索它。
Error 1 Unexpected token; 'module, class, interface, enum, import or statement' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 1 TypeScriptHTMLApp
Error 2 ';' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 27 TypeScriptHTMLApp
Error 3 Unexpected character "@". D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 3 1 TypeScriptHTMLApp
Error 4 Unexpected token; 'module, class, interface, enum, import or statement' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 3 1 TypeScriptHTMLApp
Error 5 Could not find symbol 'Component'. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 10 TypeScriptHTMLApp
Error 6 Could not find symbol 'from'. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 22 TypeScriptHTMLApp
Error 7 Could not find symbol 'Component'. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 3 2 TypeScriptHTMLApp
Error 8 Build: Unexpected token; 'module, class, interface, enum, import or statement' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 1 TypeScriptHTMLApp
Error 9 Build: ';' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 1 27 TypeScriptHTMLApp
Error 10 Build: Unexpected character "@". D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 3 1 TypeScriptHTMLApp
Error 11 Build: Unexpected token; 'module, class, interface, enum, import or statement' expected. D:\TypeScriptHTMLApp\TypeScriptHTMLApp\Component.ts 3 1 TypeScriptHTMLApp
感謝
什麼是錯誤? – developer033
共有11個錯誤。像意想不到的字符@,意外的標記..等等..拉。用errs更新原始問題 – user1480864
您正在運行哪種版本的打字稿? –