SOURCE

console 命令行工具 X clear

                    
>
console
// let value = document.querySelector('input').value;
// let count = 0;

// function InputValue(initValue){
//     this.value = initValue;
//     this.onChangeFn = null;
// }
// InputValue.prototype.emit = function(newValue){
//     this.value = newValue;
//     this.onChangeFn.call(this, this.value)

// }

// InputValue.prototype.onChange = function(fn){
//     console.log(this.value)
//     this.onChangeFn = fn
// }

// function onChange(event){
//     console.log(event.target.value)
//     value = event.target.value;
// }

// let iv = new InputValue(value);
// iv.onChange((value)=>{
//     document.querySelector('input').value = value
// })
// // iv.emit('test');

// function onButtonClik(){
//     iv.emit(count++);
// }

var input = document.querySelector("input");
var data = {};
Object.defineProperty(data, "value", {
  configurable: true,
  get: function(){
      return input.value
  },
  set: function(newValue){
    input.value = newValue;
  }
})
data.value = "sss";

input.oninput = function(){
    console.log(data.value)
}
<input value="a"/>

 <button onclick="onButtonClik()">test</button>