angular报错:Cannot read property 'showCoverDefault' of undefined

图片描述

这里我只是创建了两个组件,协商了他们路由切换
app-component.html文件:

<a [routerLink]="['/']">主页</a>
<a [routerLink]="['/product']">商品详情</a>

<router-outlet></router-outlet>

app-routing.module.ts文件:
const routes: Routes = [
  {
    path: '',component:HomeComponent
  },
  {
    path: 'product',component:ProductComponent
  }
];

这个报错并没有影响我的项目功能效果,但是很奇怪为什么会报错,而且……此时你正在观看的这个页面(思否网)好像也有这个报错。。。

备注:使用的是VSCode编译环境,Chrome浏览器,Win10系统64位,angular5,NodeJS版本8.11.2,angular-cli版本1.7.4

阅读 2.7k
1 个回答

你的代码肯定有一处是这样调用的something.showCoverDefault, 这个something没有取到值,返回undefined, 在代码里仔细找找吧。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进