<input id="input"/>
<span id="show"></span>
const data = {};
const input = document.getElementById('input');
const span= document.getElementById('span');
Object.defineProperty(data, 'text', {
set(value) {
input.value = value;
this._value = value;
},
get(){
span.innerText= this._value
}
});
input.onchange = function(e) {
data.text = e.target.value;
}
网友评论