Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio ts属性推送不';不存在于类型'上;{}';角码VS_Visual Studio_Typescript_Angular7 - Fatal编程技术网

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>();
需要检查do
console.log(this.roles)

for (let item in Role)

{
      if (item)
          {
                let temp=item;
                this.roles.push(temp);
               }
}