为什么visual studio 2015无法识别注释(Why is visual studio 2015 not recognizing annotations)

编程入门 行业动态 更新时间:2024-10-27 22:23:20
为什么visual studio 2015无法识别注释(Why is visual studio 2015 not recognizing annotations)

Visual Studio无法识别@Componetn或@View数据注释? 有谁知道为什么会发生这种情况。

更新1

我的index.html文件

<!DOCTYPE html> <html> <head> <title>Angular 2</title> <meta charset="utf-8" /> </head> <body> <my-app></my-app> <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script> <script src="https://jspm.io/system@0.16.js"></script> <script src="https://code.angularjs.org/2.0.0-beta.2/angular2.dev.js"></script> <script>System.import('app');</script> </body> </html>

我的app.ts文件

import {Component, View} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {NgFor} from 'angular2/common'; @Component({ selector: "my-app", }) @View({ templateUrl: 'mainForm.html', directives: [NgFor] }) class TodoAppComponent { todos: Array<Object>; constructor() { this.todos = [{ text: "Try Second", done: true }] } get() { return this.todos; } add($event, newtodo) { if ($event.which === 13) { this.todos.unshift({ text: newtodo.value, done: false }); newtodo.value = '' } } markAsDone(todo) { todo.done = !todo.done; } } bootstrap(TodoAppComponent);

更新2

在VS2015中构建错误

更新3

这已经在我的tsconfig.json中了

{ "version": "1.7.6", "compilerOptions": { "target": "es5", "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true }, "filesGlob": [ "./**/*.ts", "!./node_modules/**/*.ts" ], "files": [ "./app.ts", "./typings/angular2/angular2.d.ts", "./typings/es6-promise/es6-promise.d.ts", "./typings/rx/rx-lite.d.ts", "./typings/rx/rx.d.ts", "./typings/tsd.d.ts" ] }

我的目录结构,node_nodules大到扩展

Visual Studio is not recognizing the @Componetn or @View Data annotiations? Does anyone know why this might be occuring.

Update 1

My index.html file

<!DOCTYPE html> <html> <head> <title>Angular 2</title> <meta charset="utf-8" /> </head> <body> <my-app></my-app> <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script> <script src="https://jspm.io/system@0.16.js"></script> <script src="https://code.angularjs.org/2.0.0-beta.2/angular2.dev.js"></script> <script>System.import('app');</script> </body> </html>

My app.ts file

import {Component, View} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {NgFor} from 'angular2/common'; @Component({ selector: "my-app", }) @View({ templateUrl: 'mainForm.html', directives: [NgFor] }) class TodoAppComponent { todos: Array<Object>; constructor() { this.todos = [{ text: "Try Second", done: true }] } get() { return this.todos; } add($event, newtodo) { if ($event.which === 13) { this.todos.unshift({ text: newtodo.value, done: false }); newtodo.value = '' } } markAsDone(todo) { todo.done = !todo.done; } } bootstrap(TodoAppComponent);

Update 2

Build error in VS2015

Update 3

This was already in my tsconfig.json

{ "version": "1.7.6", "compilerOptions": { "target": "es5", "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true }, "filesGlob": [ "./**/*.ts", "!./node_modules/**/*.ts" ], "files": [ "./app.ts", "./typings/angular2/angular2.d.ts", "./typings/es6-promise/es6-promise.d.ts", "./typings/rx/rx-lite.d.ts", "./typings/rx/rx.d.ts", "./typings/tsd.d.ts" ] }

My Directory Structure, node_nodules to big to expand

最满意答案

问题是你试图从angular2/angular2改变angular2/angular2导入Component & View 。 所以你应该导入angular2/core而不是angular2/angular2 。

还要确保index.html上引用了所有文件。

有关详细信息,请参阅此答案

The issue is you have trying to import Component & View from angular2/angular2 which has been change in angular.beta.2.0.0. So instead you should import angular2/core instead of angular2/angular2.

Also make sure all the files are referred on the index.html.

Refer this answer for more details

更多推荐

本文发布于:2023-08-07 03:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:注释   无法识别   studio   visual   recognizing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!