[英]Angular Typescript Error - charset is deprecated. (deprecation)
I am using Angular 7. I have loadscript.directive.ts 我正在使用Angular7。我有loadscript.directive.ts
import { Directive, Input } from '@angular/core'; @Directive({ selector: '[appLoadscript]' }) export class LoadscriptDirective { @Input('appLoadscript') script: any; constructor() { } ngOnInit() { let node = document.createElement('script'); node.src = this.script; node.type = 'text/javascript'; node.async = false; node.charset = 'utf-8'; document.getElementsByTagName('head')[0].appendChild(node); } }
But I got this error: 但是我得到了这个错误:
charset is deprecated.
字符集已弃用。 (deprecation)
(弃用)
How do I resolve this error in my Angular 7? 如何在Angular 7中解决此错误?
Don't set the charset: docs 不要设置字符集: docs
If present, its value must be an ASCII case-insensitive match for "utf-8".
如果存在,则其值必须为“ utf-8”的ASCII区分大小写的匹配项。 Both it's unnecessary to specify the charset attribute, because documents must use UTF-8, and the script element inherits its character encoding from the document.
都不必指定charset属性,因为文档必须使用UTF-8,并且script元素从文档继承其字符编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.