<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<text>实现双项绑定</text>
</head>
<body>
<input type="text" id="input"></input>
<span>the input value</span>
<div id="show"></div>
</body>
<script>
var inputValue = {};
var inputDemo = document.querySelector("#input");
var showDemo = document.querySelector("#show");
Object.defineProperty(inputValue, "values", {
get: function() {
return
},
set: function(newValue) {
showDemo.innerHTML = newValue;
}
});
inputDemo.oninput = function () {
inputValue.values = this.value;
}
</script>
</html>