因最近在做瀏覽器打印界面水印的問題,用到后台動態創建標簽,樣式的處理用到了append,prend函數,Angular build打包的時候卻拋出了異常↓
ERROR in src/app/routes/contract-manage/componets/contract-preview/contract-preview.component.ts(304,28): error TS2339: Property 'prepend' does not exist on type 'HTMLElement'.
不存在prepend屬性,經過幾番周折,終於在stackoverflow上看到了大神們的解決辦法
為了正常使用它我們可以 (<any>myElement).append(otherElement) 或者 (myElement as any).append(otherElement)方式使用
當然也可以參考https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild里面的方法使用
