Proxy
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <input type="text" oninput="inputText(this)"> <h1>哈哈哈哈哈哈哈哈哈哈</h1> </body> <script> var p = new Proxy({ name: "掌声" }, { get: function (target, handler) { return target[handler]; }, set: function (target, hanlder, value) { target[hanlder] = value; update(); return true; } }); function update() { document.querySelector("h1").innerText = p.name; } function inputText(that){ p.name = that.value; } </script> </html>