加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular CLI Css Injection而不是重新加载

发布时间:2020-12-17 06:59:56 所属栏目:安全 来源:网络整理
导读:当我运行服务器时,如果我对.scss文件进行更改,则会导致页面重新加载.这很不方便,可能会丢失一些状态或开发工具更改. 通常当我处理设计时,我使用类似browseryc的东西来注入css而不刷新页面.当我必须调试一些棘手的东西时,这节省了大量的时间. 反正是否有角度c
当我运行服务器时,如果我对.scss文件进行更改,则会导致页面重新加载.这很不方便,可能会丢失一些状态或开发工具更改.

通常当我处理设计时,我使用类似browseryc的东西来注入css而不刷新页面.当我必须调试一些棘手的东西时,这节省了大量的时间.

反正是否有角度cli注入.scss更改或重新加载页面?

编辑:

从webpack文档:

HMR is an opt-in feature that only affects modules containing HMR code. One example would be patching styling through the style-loader. In order for patching to work,the style-loader implements the HMR interface; when it receives an update through HMR,it replaces the old styles with the new ones.

Similarly,when implementing the HMR interface in a module,you can describe what should happen when the module is updated. However,in most cases,it’s not mandatory to write HMR code in every module. If a module has no HMR handlers,the update bubbles up. This means that a single handler can update a complete module tree. If a single module from the tree is updated,the entire set of dependencies is reloaded.

从我听到的Angular-CLI支持HMR,但我找不到任何关于它的官方文档.

是否可以在Angular 6中实现样式加载器?

解决方法

使用Angular 7,您可以按照 this guide启用HMR. (热模块更换)

它与CSS注入不同,但它比完全重载和安装快得多.编译.

最棒的是它也适用于你的ts文件.

小附录:

我认为你可以通过注入加载改变的CSS但是遵循HMR documentation的这一部分

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读