浅谈Angular4实现热加载开发旅程
- 作者: 爱上猫的诱惑
- 来源: 51数据库
- 2021-09-03
本文介绍了angular4实现热加载开发,分享给大家,具体如下:
安装插件
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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
热点文章
Angular中响应式表单的三种更新值方法详析
7
Angularjs实现下拉框联动的示例代码
7
详解AngularJS跨页面传值(ui-router)
2
详解AngularJS1.x学习directive 中‘& ’‘=’ ‘@’符号的区别使用
3
angular2路由切换改变页面title的示例代码
4
Angular2 组件间通过@Input @Output通讯示例
5
Angularjs中ng-repeat的简单实例
3
AngularJS 中ui-view传参的实例详解
4
浅谈Angular路由守卫
4
详解基于Angular4+ server render(服务端渲染)开发教程
4