Angular 5&Go Webservices

问题描述 投票:0回答:1

Angular 5作为Golang的前端和后端以及Go中的写入服务当刷新页面时,请求被发送到服务器,这导致页面找不到404错误,因为请求以角度绕过路由器。

例如:如果我们呼叫/登录,则从路由我们能够显示一个页面,但如果刷新相同则显示为未找到页面404。

Angular5:

const AppRoutes: Routes = [
          { path: '/', component: SignupComponent, pathMatch: 'full' },
          { path: 'login' , component: LoginComponent },
          { path: 'home' , component: VisitsComponent},
          { path: 'createavisit/:id', component: VisitComponent},
      ];

走:

http.Handle("/", http.FileServer(http.Dir("./angular/dist")))
    http.HandleFunc("/register", RegisterHandler)
    http.HandleFunc("/log", LoginHandler)

有人可以帮我解决这个问题

go google-cloud-platform angular5
1个回答
0
投票

在app模块文件中导入路由模块,添加useHash:true参数。例如:RouterModule.forRoot(routes,{useHash:true})

© www.soinside.com 2019 - 2024. All rights reserved.