Angular 我能';无法使用http服务器访问页面
我试图使用http服务器-p 8081访问该页面,但浏览器显示“找不到该网址的网页:” 我运行ngbuild--prod并转到dist文件夹,然后运行httpserver-p8081 root-routing.module.ts具有Angular 我能';无法使用http服务器访问页面,angular,Angular,我试图使用http服务器-p 8081访问该页面,但浏览器显示“找不到该网址的网页:” 我运行ngbuild--prod并转到dist文件夹,然后运行httpserver-p8081 root-routing.module.ts具有 import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { pat
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: '/app/home', pathMatch: 'full' },
{ path: 'account', loadChildren: 'account/account.module#AccountModule', data: { preload: true }
},
{
path: 'app',
loadChildren: 'app/app.module#AppModule',
data: { preload: true }
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
export class RootRoutingModule { }
如何访问我的主页?我遗漏了什么吗?我发现http服务器有问题。我安装了http-server@0.9.0我发现http服务器有问题。我安装了http-server@0.9.0我也遇到了同样的问题,据我所知,http服务器不支持SPA服务,至少如果您直接打开指向特定页面的url,它就不支持SPA服务。相反,它将尝试以给定路径提供文件。例如:
/home/hello
不会解析为您的angular路由器路径,而是尝试提供可能找不到的/home/hello/index.html
为了防止这个问题,我使用了
我也有同样的问题,据我所知,http服务器不支持服务SPA,至少如果您直接打开指向特定页面的url,就不支持服务SPA。相反,它将尝试以给定路径提供文件。例如:
/home/hello
不会解析为您的angular路由器路径,而是尝试提供可能找不到的/home/hello/index.html
为了防止这个问题,我使用了
可能您将项目命名错误:
http-server -p 8080 -c-1 dist/<project-name>
http服务器-p8080-c-1区/
检查您的dist文件夹以查看应用程序的名称。很可能只是“应用程序”。可能您将项目命名错误:
http-server -p 8080 -c-1 dist/<project-name>
http服务器-p8080-c-1区/
检查您的dist文件夹以查看应用程序的名称。很可能只是“应用程序”。它服务正确吗?(没有家)。编辑:您尝试访问的链接不应该是:?对不起,我的错误。我访问了localhost:8081并重定向到app/home,但仍然无法访问其他路由是否有效?它是否正常工作?(没有家)。编辑:您尝试访问的链接不应该是:?对不起,我的错误。我访问了localhost:8081并重定向到app/home,但仍然无法访问其他路由是否有效?