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;
修改后
前者是指我们不确定是否会传入这个参数,后者是指我们一定会给这个参数赋值
标签:
相关文章
-
无相关信息