Angular 在应用程序组件中添加文档标记会导致前置错误
我正在尝试在HTML文档中加载脚本。我得到的错误如下“prepend”函数。我在Angular应用程序组件的构造器文档中使用它Angular 在应用程序组件中添加文档标记会导致前置错误,angular,Angular,我正在尝试在HTML文档中加载脚本。我得到的错误如下“prepend”函数。我在Angular应用程序组件的构造器文档中使用它 Failed to load resource: net::ERR_NAME_NOT_RESOLVED 我的添加标记代码是 const script = document.createElement('script'); script.async = true; script.type = 'text/javascript';
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
我的添加标记代码是
const script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.src = 'https://www.googletagmanager.com/gtag/js?id=' + const_key;
document.head.prepend(script);
请帮忙