File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -111,3 +111,16 @@ npm run dev
111
111
- 但在setup中<strong style =" color :#DD5145 " >不能访问到</strong >Vue2.x配置(data、methos、computed...)。
112
112
- 如果有重名, setup优先。
113
113
2 . setup不能是一个async函数,因为返回值不再是return的对象, 而是promise, 模板看不到return对象中的属性。(后期也可以返回一个Promise实例,但需要Suspense和异步组件的配合)
114
+
115
+
116
+ ## 2.ref函数
117
+
118
+ - 作用: 定义一个响应式的数据
119
+ - 语法: ``` const xxx = ref(initValue) ```
120
+ - 创建一个包含响应式数据的<strong style =" color :#DD5145 " >引用对象(reference对象,简称ref对象)</strong >。
121
+ - JS中操作数据: ``` xxx.value ```
122
+ - 模板中读取数据: 不需要.value,直接:``` <div>{{xxx}}</div> ```
123
+ - 备注:
124
+ - 接收的数据可以是:基本类型、也可以是对象类型。
125
+ - 基本类型的数据:响应式依然是靠`` Object.defineProperty() `` 的``` get ``` 与``` set ``` 完成的。
126
+ - 对象类型的数据:内部 <i style =" color :gray ;font-weight :bold " >“ 求助 ”</i > 了Vue3.0中的一个新函数—— ``` reactive ``` 函数。
You can’t perform that action at this time.
0 commit comments