一、罕用语法上的不同
1.data
2.所有的内容包在setup外面,在template应用的数据和办法须要return
二、应用组合式api的益处
1.按性能划分,便于保护
依照原来的写法,实现一个性能,我要写在不同的生命周期外面,不聚合~
Options API
Composition API
我的项目上的例子
2.逻辑复用
三、如何封装一个逻辑函数
其实逻辑复用函数简略了解就是 有状态的函数
比函数多了状态,比组件少了视图。
getCertificateList
useSearch
useBoolean
useAsync
库函数
1.https://github.com/vueuse/vueuse
2.https://github.com/pikax/vue-composable
3.https://github.com/dewfall123/ahooks-vue
友情链接:
1.react hooks
助力拥抱react hooks:https://zhuanlan.zhihu.com/p/103150605?utm_source=wechat_session
react hooks函数库:https://github.com/alibaba/hooks
2.composition-api
作者分享:https://github.com/Bin-FE/binfe-salon-ppt
github:https://github.com/vuejs/composition-api
官网文档:https://v3.cn.vuejs.org/guide/composition-api-introduction.html
疾速上手文档:https://mp.weixin.qq.com/s/GaII_4o69SGpI7IPeIMZSw