简体   繁体   English

如何同时使用 Vue-Router 和 Gorilla Mux 路由器

[英]How to use both Vue-Router and Gorilla Mux Router

I started to create a web app using Vue JS as the front end framework.我开始使用 Vue JS 作为前端框架创建一个 web 应用程序。 In this process, I'm using Vue-Router to route paths to my vue components.在这个过程中,我使用 Vue-Router 将路径路由到我的 vue 组件。 And I'm serving this web app using Go with gorilla mux as my router.我正在使用 Go 和大猩猩多路复用器作为我的路由器来服务这个 web 应用程序。

Here I am not able to load any component to <router-view></router-view> in App.vue .在这里,我无法将任何组件加载到App.vue<router-view></router-view>

I found a similar question here .我在这里发现了一个类似的问题。 And I tried removing mode: 'history' but no luck.我尝试删除mode: 'history'但没有运气。 In the comments, it was mentioned that he let Go redirect all not-found URLs to /# + r.URL.Path .在评论中提到,他让 Go 将所有未找到的 URL 重定向到/# + r.URL.Path I didn't understand this bit.这一点我没看懂。

I'll appreciate if anyone can guide me with some example.如果有人能用一些例子指导我,我将不胜感激。

If possible, don't serve the front end from within the Go app.如果可能,不要从 Go 应用程序中提供前端服务。 Here's what I do:这就是我所做的:

Go app is the backend, provides RESTful APIs for the front end to use. Go app 为后端,提供 RESTful API 供前端使用。

There's a nginx server setup as a reverse proxy for the Go app.有一个 nginx 服务器设置作为 Go 应用程序的反向代理。

nginx serves the front end directly nginx 直接服务于前端

I use nginx to serve the Go backend in a certain url location or different port我使用 nginx 在某个 url 位置或不同端口中为 Go 后端提供服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM