[英]useRef Typescript error: Property 'current' does not exist on type 'HTMLElement'
[英]Typescript Error: Property 'append' does not exist on type 'HTMLElement'
在嘗試將已編譯的角度1.5模板附加到現有HTMLElement
時,我收到了Typescript 2.2.1編譯錯誤。
碼:
$document.find(scope.target)[0].append($compile(menu)(scope)[0]);
編譯錯誤:
[ts] Property 'append' does not exist on type 'HTMLElement'
我搜索了類型定義,但沒有看到append()
的簽名。
關於我應該使用哪種類型或版本的打字稿的任何想法?
謝謝!
這里與TypeScript無關。
要調用的正確方法是appendChild
:
https://developer.mozilla.org/en/docs/Web/API/Node/appendChild
append
是一個jQuery方法,如果你想使用它你可以做:
$document.find(scope.target).append($compile(menu)(scope)[0]);
它也應該工作。
我希望它有所幫助
HTMLElement上有一個append / prepend函數。 它目前仍處於試驗階段的問題 。
為了使用它而不會從TypeScript中獲取錯誤,我將其用作任何¯\\ _(ツ)_ /¯ (<any>myElement).append(otherElement)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.