素材巴巴 > 程序开发 >

angular报错:Property ‘selectedHe‘ has no initializer and is not definitely assigned in the constructor

程序开发 2023-09-03 17:15:50

或者这个报错:Refused to load the image’http://localhost:4200/favicon.ico’ because it violates the following Content Security Policy directive: “default-src ‘none’”. Note that ‘img-src’ was not explicitly set, so ‘default-src’ is used as a fallback.

在这里插入图片描述
在报错地方如上图:加上感叹号:selectedHero!: Hero;或者加问号:selectedHero?: Hero;

在报错地方如上图:加上感叹号:selectedHero!: Hero;或者加问号:selectedHero?: Hero;

修改后
前者是指我们不确定是否会传入这个参数,后者是指我们一定会给这个参数赋值
在这里插入图片描述


标签:

素材巴巴 Copyright © 2013-2021 http://www.sucaibaba.com/. Some Rights Reserved. 备案号:备案中。