Last active
May 24, 2023 14:53
-
-
Save sunzsh/874d2e5e214a660fd5b8f75fea0a5b5a to your computer and use it in GitHub Desktop.
react文本框赋值方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){setNativeValue=function(qs,value){const element=document.querySelector(qs);const valueSetter=Object.getOwnPropertyDescriptor(element,'value').set;const prototype=Object.getPrototypeOf(element);const prototypeValueSetter=Object.getOwnPropertyDescriptor(prototype,'value').set;if(valueSetter&&valueSetter!==prototypeValueSetter){prototypeValueSetter.call(element,value)}else{valueSetter.call(element,value)}element.dispatchEvent(new Event('input',{bubbles:true}))};})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment