简体   繁体   English

未捕获的类型错误:无法读取未定义的属性(读取“设置”)

[英]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.

相关问题 未捕获的类型错误:无法读取未定义的属性(读取“8”) - Uncaught TypeError: Cannot read properties of undefined (reading '8') 未捕获的类型错误:无法读取未定义的属性(读取“0”) - Uncaught TypeError: Cannot read properties of undefined (reading '0') 未捕获的类型错误:无法读取未定义的属性(读取“0”) - Uncaught TypeError: Cannot read properties of undefined (reading '0') 未捕获的类型错误:无法读取未定义的属性(读取“”) - Uncaught TypeError: Cannot read properties of undefined (reading '') 未捕获的类型错误:无法读取 null 的属性(正在读取“切片”)------ 未捕获的类型错误:无法读取未定义的属性(正在读取“过滤器”) - Uncaught TypeError: Cannot read properties of null (reading 'slice') ------ Uncaught TypeError: Cannot read properties of undefined (reading 'filter') Uncaught TypeError TypeError:无法读取未定义的属性(读取“路径”) - Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'path') TypeError:无法读取未定义的属性(读取“设置”) - TypeError: Cannot read properties of undefined (reading 'set') 未捕获的类型错误:无法读取未定义的属性(读取“目标”)和(读取“值”) - Uncaught TypeError: Cannot read properties of undefined (reading 'target') & (reading 'value') 未捕获的类型错误:无法读取未定义的属性(读取“未定义”) - Uncaught TypeError: Cannot read properties of undefined (reading 'undefined') Redux 工具包:未捕获的类型错误:无法读取未定义的属性(读取“类型”) - Redux toolkit: Uncaught TypeError: Cannot read properties of undefined (reading 'type')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM