You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
604 B
27 lines
604 B
2 years ago
|
# model的生命周期
|
||
|
|
||
|
FineUI组件有很多生命周期,`beforeRender`,`mounted`,`destoryed等`.
|
||
|
|
||
|
model同样提供了一些生命周期供我们使用,`init` `created` `destroyed`
|
||
|
|
||
|
`init`生命周期触发时此刻什么都没有,无法获取state与context,适用于初始化一些状态无关的东西
|
||
|
`created`生命周期触发时此时已经可以获取state与context的值了
|
||
|
`destroyed`生命周期是在model完成销毁后触发,此时可以做一下收尾工作
|
||
|
|
||
|
```javascript
|
||
|
class Model extends Model {
|
||
|
|
||
|
init() {
|
||
|
|
||
|
}
|
||
|
|
||
|
created() {
|
||
|
|
||
|
}
|
||
|
|
||
|
destroyed() {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
```
|