将dist复制到Web服务器时出现Angular 5错误404 [英] Angular 5 error 404 when copying dist to webserver
问题描述
我做了一个简单的Angular 5封面,说我仍在构建此网站.
ng serve
在本地运行良好,但现在我想在学校的网站此处进行托管我找不到所有这些404资源,而我所做的就是在运行ng build --prod
之后将dist/文件夹中的内容复制到Web服务器上的www/文件夹中.
I made a simple Angular 5 cover to say that I'm still constructing this website.
ng serve
works fine locally, but now I wanted to host this on my schools website here and I get all these 404 resources not found and all I did was copy whats in the dist/ folder after running ng build --prod
to the www/ folder on the webserver.
此cli版本的角度为5:
It's angular 5 with this cli version:
"@angular/cli": "~1.7.1",
"@angular/compiler-cli": "^5.2.0",
我试图将另一个推送到github-pages,这也有相同的问题 githubpages 回购是回购,但它几乎是一个空的回购.
I tried to push another one to github-pages and this has the same problem githubpages the repo is repo but it's almost an empty repo.
推荐答案
在构建应用程序时,您需要添加--base-href
参数,如下所示:
You need to add --base-href
parameter when you build your application, like this:
ng build --prod --base-href /~320255eg/
其中/~320255eg/
代表您的应用程序的路径.
Where /~320255eg/
represents the path to your application.
这篇关于将dist复制到Web服务器时出现Angular 5错误404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!