使用 Angular/React/Vue 的一些技巧
中心思想
当下流行的三大前端框架,它们都需要掌握:
🌻HTML视图的编写与封装 🌻数据的更新与时机

HTML视图的编写(1/2)
模版语法,一般都包含插值表达式、属性绑定、事件绑定;
在 Angular 中通过模板语法表达 HTML
在 React 中通过 JSX 语法表达 HTML
在 Vue 中通过模版语法表达 HTML
HTML视图的封装(2/2)
在 Angular 中定义一个组件,并在其他地方使用它
在 React 中定义一个组件,并在其他地方使用它
在 Vue 中通过模版语法表达 HTML

数据的更新方法(1/2)
在 Angular 中仅仅需要在 component.ts 中更新数据,就能更新视图状态;
在 React 中需要使用 setState 来更新视图状态,这是一种单向数据流;
在 Vue 中的数据都是响应式的,更新数据会自动触发视图更新;
👋Vue的数据更新原理
数据更新的时机(2/2)
Angular:
ngOnChanges
> ngOnInit/ngDoCheck
> ngAfterContentInit
/ngAfterContentChecked
> ngAfterViewInit
/ngAfterViewChecked
>
ngOnDestroy
React:
创建时:
constructor
> getDerivedStateFromProps > render > componentDidMount
更新时:
static getDerivedStateFromProps > shouldComponentUpdate
> render
> getSnapshotBeforeUpdate > componentDidUpdate
销毁时:
componentWillUnmount
Vue:
before / created
> before / mounted
> before / updated
> before / destoryed

一些面试题