feat(reactivity): 实现响应式系统基础功能
- 新增 baseHandlers.ts 文件,定义响应性 handler - 在 reactivity 模块中导出 reactive 函数 - 将 vue 主入口改为导出 reactive,移除测试代码 - 添加 reactive.html 示例文件用于测试响应式功能 - 实现 reactive 函数,支持创建复杂数据类型的响应式对象 - 使用 WeakMap 缓存代理对象,避免重复代理
This commit is contained in:
19
packages/vue/examples/reactivity/reactive.html
Normal file
19
packages/vue/examples/reactivity/reactive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Document</title>
|
||||
<script src="../../dist/vue.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
const { reactive } = Vue
|
||||
console.log(reactive)
|
||||
const obj=reactive({
|
||||
name:'张三'
|
||||
})
|
||||
console.log(obj)
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,3 +1 @@
|
||||
import { isArray } from '@vue/shared'
|
||||
|
||||
console.log(isArray([]))
|
||||
export { reactive } from '@vue/reactivity'
|
||||
|
||||
Reference in New Issue
Block a user