javascript 赋值 react input的输入框
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}))
};
setNativeValue(‘#testtt’, ‘testttt’);
})();