-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# 介绍 | ||
# 项目介绍 | ||
|
||
本文档是基于[mini-vue](https://github.com/cuixiaorui/mini-vue)框架进行源码学习,深入vue框架底层原理并进行剖析,尝试个人再造vue3框架甚至于添加新特性 | ||
|
||
## 目录 | ||
|
||
- 响应式 | ||
- [ref](/reactive/ref.md) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Reactive | ||
|
||
一般而言,数值、布尔值、字符串、数组变量的响应式使用`ref`,而对象的响应式使用`reactive`,可以深度检测内部对象的变更 | ||
|
||
## 实现分析 | ||
|
||
通过`reactive`双向绑定的vue文件样例,我们分析一下需要实现的功能特性 | ||
|
||
```vue | ||
<template> | ||
<input v-model:value="form.username" type="text" name="username" /> | ||
<input v-model:value="form.password" type="password" name="password" /> | ||
</template> | ||
<script setup> | ||
import { reactive, watchEffect } from 'vue' | ||
const form = reactive({ | ||
username: '', | ||
password: '' | ||
}) | ||
watchEffect(() => { | ||
console.log(form.username) | ||
console.log(form.password) | ||
}) | ||
</script> | ||
``` | ||
|
||
从上述样例可以看出,`reactive`作为函数,参数为对象进行调用,返回一个变量,该变量仍然具有对象的特征 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.