<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
输入1<input type="text" oninput="ch()"><br>
输入2<input id="test" type="text">
</body>
<script type="text/javascript">
function ch(e){
var e = e||event;
var text = e.target.value;
a.b = text;
console.log(a.b)
}
var a = {};
bValue = 1;
Object.defineProperty(a, "b", {
set: function(value) {
document.querySelector("#test").value = value;
},
get: function() {
return document.querySelector("#test").value;
}
})
</script>
</html>
手写双向绑定
最新推荐文章于 2024-09-10 17:33:29 发布