Angular + Electron - 应用程序中断更新或更改
问题描述:
如果导航到路由localhost:4200/login进行更改或刷新,它可以正常工作。Angular + Electron - 应用程序中断更新或更改
如果我导航到路由localhost:4200 /主,这是一个子模块(受authguard保护),如果我对这些页面中的任何组件进行更改或刷新,我会得到以下错误。
profile:16 GET http://localhost:4200/main/inline.bundle.js net::ERR_ABORTED
12:53:35.010 profile:16 GET http://localhost:4200/main/polyfills.bundle.js net::ERR_ABORTED
12:53:35.019 profile:16 GET http://localhost:4200/main/styles.bundle.js net::ERR_ABORTED
12:53:35.053 profile:16 GET http://localhost:4200/main/vendor.bundle.js net::ERR_ABORTED
12:53:35.053 profile:16 GET http://localhost:4200/main/main.bundle.js 404 (Not Found)
我使用纳克服务--watch
@angular/cli: 1.4.5
node: 6.11.3
os: linux x64
@angular/animations: 4.4.4
@angular/cdk: 2.0.0-beta.12
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/material: 2.0.0-beta.12
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.4
@angular/language-service: 4.4.4
typescript: 2.5.3
另外需要注意的是它总能成功编译为我的应用程序。
chunk {common} common.chunk.js, common.chunk.js.map (common) 13.8 kB {main} [rendered]
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry]
chunk {main} main.bundle.js, main.bundle.js.map (main) 64.2 kB {vendor} [initial]
chunk {main.module} main.module.chunk.js, main.module.chunk.js.map() 83.2 kB {main}
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 217 kB {inline} [initial]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 66.4 kB {inline} [initial]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.53 MB [initial]
webpack: Compiled successfully.
答
根据this post,问题在于Electron处理HTML5样式的URL。为了得到它的工作,你应该需要做的是告诉RouterModule使用混编网址,以类似的方式,以角1
这看起来像下面这样:
@NgModule({
imports: [
BrowserModule,
FormsModule,
RouterModule.forRoot(routes, { useHash: true }) // .../#/your-route/
]...
尝试 NPM卸载-g角-CLI @角/ CLI NPM缓存清理 NPM安装-g @角/ CLI @最新 –
嘿,我只是想如你所说,我仍然有同样的问题,感谢sugguestion寿 – KHAN
您的index.html头部是否有 标签?如果你不尝试添加一个像 ,看看是否有帮助。 –
jeddai