请问下OnInit 是什么呢? export class ScrollableTabComponent implements OnInit

来源:2-6 【组件封装】分离封装第一个组件

慕虎5224321

2019-09-04

老师,请问下OnInit 是什么呢? export class ScrollableTabComponent implements OnInit
我代码报错: ERROR in src/app/components/scrollable-tab/scrollable-tab.component.ts(21,14): error TS2420: Class ‘ScrollableTabComponent’ incorrectly implements interface ‘OnInit’.
Property ‘ngOnInit’ is missing in type ‘ScrollableTabComponent’ but required in type ‘OnInit’.

网上也没查到 OnInit 是什么
写回答

1回答

接灰的电子产品

2019-09-04

是组件的生命周期函数之一。后面会讲的,但你如果实现 OnInit,就需要有 ngOnInit() 函数,你报的错就是没有这个函数;去git中看一下源码就明白了

0
0

Angular 开发拼多多webapp 从基础到项目实战

高仿拼多多WebApp,带你在实战环境中学习Angular

1317 学习 · 451 问题

查看课程