【发布时间】:2021-01-09 03:09:42
【问题描述】:
这是我的 Angular 函数。
getUserdata(){
console.log("Test")//This is Working
const getHtmlContent = document.getElementById('getContent') as HTMLElement;
const getTextContent = getHtmlContent.innerText;
console.log("Test");//This is not working
console.log(getTextContent);//This is not working
}
【问题讨论】:
-
getHtmlContent3未定义。 post edit你能提供你的HTML或可重现的例子 -
控制台有错误吗?如果在 DOM 中找不到
#getContent,您应该看到cannot read property innerText of null或其他内容。 -
如果你使用 Angular 为什么你使用
getElementById?
标签: angular