问题
I'm working on an Angular 4 web app and I need to use PathLocationStrategy
(not HashLocationStrategy
).
The only problem with PathLocationStrategy
is that when I refresh a page, I instantly get a blank page with 404 errors in the console... Which is normal with PathLocationStrategy
.
Once on a server, I can fix that by redirecting the routes to point on index.html. But how to fix this issue on localhost when I launch my app with ng serve
?
It would be ideal since I'm working in "livereload", because when I update a file, I get a blank page and I have to restart from the base path.
So is it possible to use PathLocationStrategy
when working in localhost?
回答1:
ng serve
take care of both Strategy. Locally I am using PathLocationStrategy
来源:https://stackoverflow.com/questions/52738574/how-to-use-pathlocationstrategy-on-localhost