<body> <p id="p1">222</p> <input type="text" id="inp"/> </body> <script> const Book = { name: '' } Object.defineProperty(Book, 'msg', { get() { return this.name }, set(v) { Book.name = v; p.innerHTML = v; inp.value = v; } }) var p = document.getElementById('p1') var inp = document.getElementById('inp') //input框写入数据 inp.oninput = function (e) { Book.msg = e.target.value;goo } </script>