Angular2:在子文件夹

时间:2018-01-22 22:53:27

标签: angular apache deployment angular-cli

我试图在我的apache2服务器上部署我的Angular2应用程序。我没有部署到根目录中,而是部署到子文件夹中:/ var / www / html / demo / tppj /

我使用以下命令构建了我的应用程序:ng build --base-href =" / demo / tppj /"

当访问url mydomain / demo / tppj /时,它工作得很好但是如果我刷新页面,我会从/ var / www / html /的索引中获取一些代码。

有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

这似乎是一个服务器问题,我并不熟悉。但是,似乎使用哈希导航可以解决这个问题。

RouterModule.forRoot(routes, { useHash: true })

答案 1 :(得分:-1)

你知道吗--deploy-url?

--deploy-url "/demo/tppj/"会在css中引用的所有* .budled.js文件和资源之前添加/ demo / tppj /,但不会在html中引用的图像中添加。

这些链接可能会对您有所帮助。

https://github.com/angular/angular-cli/issues/1080

https://github.com/angular/angular-cli/issues/4517

https://github.com/creativetimofficial/material-dashboard-pro-angular/issues/204

感谢。

相关问题