<script> let obj = {} let inp = document.getElementById('input'); let p = document.getElementsByTagName('p')[0]; Object.defineProperty(obj,'name',{ get(){ console.log('取'); }, set(val){ inp.innerText = val; } })
inp.addEventListener('keyup',function(e){ p.innerText = e.target.value; }) </script> </body> </html>