本文介紹了Angular4實現熱加載開發,分享給大家,具體如下:
安裝插件
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 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.tsdeclare var module: NodeModule;interface NodeModule { hot: any;}啟用熱加載
// package.jsonng serve -H d.io --port 3000 --hmr --proxy-config=./proxy.json
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。
新聞熱點
疑難解答
圖片精選