当前位置:网站首页>Composition API的优势
Composition API的优势
2022-07-26 01:54:00 【_洋】
Composition API(组合式API)是vue3的写法,通俗地理解组合式API就是在setup中对数据(data),方法(methods)等进行配置。
vue2中使用的是Options API(配置式API)
Options API
使用传统OptionsAPI中,新增或者修改一个需求,就需要分别在data,methods,computed里修改。
功能不能独立出来,如果功能特别多就显得很乱。
图示:(一个颜色代表一个功能)
Composition API
我们可以更加优雅的组织我们的代码,函数。让相关功能的代码更加有序的组织在一起。
如:我们使用hook函数,将一个功能放在一个hook函数中,需要使用的时候直接在setup中使用.use引入即可。实现了功能的分离,代码更加有序。
图示:(一个颜色代表一个功能)
边栏推荐
- G. Count the trains (thought set + two points)
- PHP Alipay transfer to Alipay account
- Is it safe for Huatai Securities to open an account online? How to handle it?
- AutoCAD -- Method of calculating area
- MPLS知识点
- Qt程序美化之样式表的使用方法,Qt使用图片作为背景与控件透明化,Qt自定义按钮样式
- 元素和小于等于阈值的正方形的最大边长(来源:力扣(LeetCode))
- F. Equal multisets (greedy)
- Silicon Valley classroom - official account cloud on demand Silicon Valley classroom microservice project practical notes
- flutter 下 grpc list没有Setter 方法 ,如何使用相关属性
猜你喜欢
![[Verilog digital system design (Xia Yuwen) 4 ----- basic concepts of Verilog syntax 2]](/img/fe/746ecaf4123072cca59d7510e9796c.png)
[Verilog digital system design (Xia Yuwen) 4 ----- basic concepts of Verilog syntax 2]

CPU的三种模式

The e-commerce project is written in the resume. How to answer it during the interview

元素和小于等于阈值的正方形的最大边长(来源:力扣(LeetCode))

PHP Alipay transfer to Alipay account

flutter 下 grpc list没有Setter 方法 ,如何使用相关属性

How to display numbers / English time in Excel

图像批处理高斯滤波降噪+峰值信噪比计算

D. Rating compression (thinking + double pointer)

Worthington产气荚膜梭菌神经氨酸酶的特征及测定
随机推荐
重发布基础与配置
npm ERR! code ETIMEDOUTnpm ERR! syscall connectnpm ERR! errno ETIMEDOUTnpm ERR! network request t
Redis集群搭建(基于6.x)
3、 Pinda general permission system__ pd-tools-swagger2
Silicon Valley classroom - official account cloud on demand Silicon Valley classroom microservice project practical notes
BGP知识点总结
在Anaconda 中安装和使用R
【独立站建设】shopify卖家:学会这几点,网上商店销量翻倍!
推荐系统-协同过滤在Spark中的实现
旅行 (拆点分层)
AttributeError: ‘Document‘ object has no attribute ‘pageCount‘
Mark and lightbulbs (thinking)
Overview of database stress testing methods
ABC find 4-cycle (pigeon nest theorem)
我mysql to mysql数据表同步,代码上只有写在第一个顺序上的生效 其余的不生效,这个可能是
Video game quiz? I think it's useless. It's better to do these well!
How to display numbers / English time in Excel
给RestTemplate添加拦截器记录请求响应,还需解决流只读一次的问题
Image batch processing Gaussian filter noise reduction + peak signal-to-noise ratio calculation
Speech comprehension - structural analysis exercise of fragment reading