corizhang 2023-09-10 23:43:43 +08:00
parent e2150600c2
commit 2501e0a53a
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>

28
vue/数据代理.html Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据代理</title>
</head>
<body>
<!-- 数据代理: 通过一个对象代理另一个对象中属性的操作(读/写) -->
<script type="text/javascript" >
let obj1 = {
x:100
}
let obj2 = {
y:200
}
Object.defineProperty(obj2,'x',{ //往obj2身上添加一个x属性其值为obj1的x属性值
get(){
return obj1.x
},
set(value){
obj1.x = value
}
})
</script>
</body>
</html>