Angular 4 开启热加载开发旅程
发布时间:2020-12-17 08:54:58 所属栏目:安全 来源:网络整理
导读:安装插件 npm install @angularclass/hmr -D 配置插件 // main.tsif (environment.production) { enableProdMode();}else { if (module.hot) { module.hot.accept(); module.hot.dispose(() = { let _styles = document.head.querySelectorAll('style'); let
安装插件npm install @angularclass/hmr -D 配置插件// main.ts if (environment.production) { enableProdMode(); }else { if (module.hot) { module.hot.accept(); module.hot.dispose(() => { let _styles = document.head.querySelectorAll('style'); let styles = Array.prototype.slice.call(_styles); styles .filter((style: any) => style.innerText.indexOf('_ng') !== -1) .map((el: any) => document.head.removeChild(el)); }) } } platformBrowserDynamic().bootstrapModule(AppModule); 配置Typescript// typings.d.ts declare var module: NodeModule; interface NodeModule { hot: any; } 启用热加载// package.json ng serve -H d.io --port 3000 --hmr --proxy-config=./proxy.json (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |