且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 ngif 不从我的代码中删除脚本标签?

更新时间:2023-12-05 18:55:16

它们是否被移除并不重要.到 angular 引导程序并开始 DOM 操作时,浏览器将编译所有脚本标签.

It wouldn't matter if they were removed or not. By the time angular bootstraps and starts DOM manipulation all script tags will have been compiled by browser.

删除脚本标记不会删除已经编译的代码.

Removing a script tag does not remove the code that has already been compiled.

没有更多关于您要完成什么或脚本做什么的信息,目前只能提供这些信息.

Without a lot more information on what it is you are trying to accomplish , or what the scripts do, this is about all that can be offered for now.

我建议您阅读有关在将 html 编译为 DOM 时浏览器如何处理网页的基础知识.一旦它遇到带有 src 的脚本标签,就会对该文件发出请求,并且无法拦截它.

I would suggest you read up on the basics of how a web page gets processed by the browser as the html gets compiled to the DOM. The instant it encounters a script tag with an src , a request is made for that file and there is no way to intercept it.