<!DOCTYPE html>标签:obj2,obj,Title,value,js,vue,let,018,set From: https://blog.51cto.com/u_15356972/6085199
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<script type="text/javascript">
//数据代理,通过一个对象,对另外一个对象的属性进行修改
let obj = {x:100};
let obj2 = {y:200};
Object.defineProperty(obj2,'x',{
get:function () {
return obj.x;
},
set(value){
obj.x = value;
}
});
</script>
</body>
</html>