[英]Error: src/app/components/button/button.component.ts:11:27 - error TS1005: '(' expected
I'm new to Angular and I'm following a tutorial to get started and I'm getting this error in line 11, even if '(' is present我是 Angular 的新手,我正在按照教程开始,我在第 11 行遇到了这个错误,即使存在 '('
Error: src/app/components/button/button.component.ts:11:27 - error TS1005: '(' expected.错误:src/app/components/button/button.component.ts:11:27 - 错误 TS1005: '(' 预期。
this is the code of button.component.ts这是 button.component.ts 的代码
import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-button',
templateUrl: './button.component.html',
styleUrls: ['./button.component.css']
})
export class ButtonComponent implements OnInit {
@Input() color: string;
@Input() text: string;
@Output() btnEvetn: new EventEmitter(); //line 11
constructor() { }
ngOnInit(): void {}
onClick()
{
console.log("Added");
}
}
also, I'm getting those other errors, all of them on line 11另外,我遇到了其他错误,所有这些错误都在第 11 行
Error: src/app/components/button/button.component.ts:11:27 - error TS2314: Generic type 'EventEmitter' requires 1 type argument(s).错误:src/app/components/button/button.component.ts:11:27 - 错误 TS2314:通用类型“EventEmitter”需要 1 个类型参数。
Error: src/app/components/button/button.component.ts:11:39 - error TS1441: Cannot start a function call in a type annotation.错误:src/app/components/button/button.component.ts:11:39 - 错误 TS1441:无法在类型注释中启动函数调用。
Error: src/app/components/button/button.component.ts:11:40 - error TS1068: Unexpected token.错误:src/app/components/button/button.component.ts:11:40 - 错误 TS1068:意外令牌。 A constructor, method, accessor, or property was expected.需要构造函数、方法、访问器或属性。
@Output() btnEvetn: EventEmitter<void> = new EventEmitter();
Use the type with EventEmitter, If you have to emit data of type string you can use as将类型与 EventEmitter 一起使用,如果必须发出字符串类型的数据,则可以用作
@Output() btnEvetn = new EventEmitter<string>();
In the case you are not sure about the data type use any如果您不确定数据类型,请使用任何
@Output() btnEvetn = new EventEmitter<any>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.