[英]Uncaught TypeError: Cannot read properties of undefined (reading 'set')
Can anybody help me out with why my browser's console is showing this error when I hit:任何人都可以帮助我了解为什么我的浏览器控制台在我点击时显示此错误:
Object.getOwnPropertyDescriptor(HTMLElement.prototype, "innerHTML").set;
Actually, I need access to the span tag to update the text but I'm blocked due to an error:实际上,我需要访问 span 标签来更新文本,但由于错误而被阻止:
Uncaught TypeError: Cannot read properties of undefined (reading 'set')
The actual code for which I need a solution with span tag is below:我需要带有 span 标签的解决方案的实际代码如下:
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
nativeInputValueSetter.call(input, 'react 16 value');
var ev2 = new Event('input', { bubbles: true});
input.dispatchEvent(ev2);
that's not the right way to tickle with DOM, try to use ways like accessing elements with querySelector (it's just one way you can do).这不是处理 DOM 的正确方法,请尝试使用诸如使用querySelector访问元素之类的方法(这只是您可以做的一种方法)。 it can be something like this:
它可以是这样的:
document.querySelector('#related-id').innerText = 'replacing text'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.