Visual studio ts属性推送不';不存在于类型'上;{}';角码VS
我创建了一个数组Visual studio ts属性推送不';不存在于类型'上;{}';角码VS,visual-studio,typescript,angular7,Visual Studio,Typescript,Angular7,我创建了一个数组 messages: string[] =[]; 之后,我尝试推送一个字符串值 add(message: string){ this.messages.push(message); } 在visual studio中,我遇到以下错误: [ts] Property 'push' does not exist on type '{}'. 您可以尝试此消息:string[]=new Array()试试我在项目中使用的这个 public ro
messages: string[] =[];
之后,我尝试推送一个字符串值
add(message: string){
this.messages.push(message);
}
在visual studio中,我遇到以下错误:
[ts] Property 'push' does not exist on type '{}'.
您可以尝试此消息:string[]=new Array()代码>试试我在项目中使用的这个
public roles = new Array<any>();
需要检查doconsole.log(this.roles)代码>
for (let item in Role)
{
if (item)
{
let temp=item;
this.roles.push(temp);
}
}