refactor(vue): 构建ref简单数据类型的响应性
This commit is contained in:
21
packages/vue/examples/reactivity/ref-shallow.html
Normal file
21
packages/vue/examples/reactivity/ref-shallow.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<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>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
<script>
|
||||
const { ref,effect } = Vue
|
||||
const obj=ref('张三')
|
||||
effect(()=>{
|
||||
document.querySelector('#app').innerText=obj.value
|
||||
})
|
||||
setTimeout(()=>{
|
||||
obj.value='李四'
|
||||
},2000)
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user