Vue 路由器 - 如何在生产中的新标签页中打开?

问题描述

我正在使用 Vue、Vuetify,我的数据库位于 postgresql 中,带有来自 postgREST (https://postgrest.org/en/stable/) 的 API 后端。使用本地主机和哈希模式时,本地一切正常。使用以下语法时,我可以在新选项卡中打开组件产品:

const route = this.$router.resolve({ path: `/product/${value.id}` }) (1)
window.open(route.href,'_blank')                                    (2)

但是,在带有 postgREST-server 的生产环境中,在新标签页中打开时,我得到了错误的 url :

http:server_name/api/#/product/1                                     (3)

当我从上面的 url (3) 中删除 /api 并像这样重写它时:

http:server_name/#/product                                           (4)

我得到了正确的页面
是否可以编写一个可能的 Nginx 规则来确保 http:server_name/api/#/product/1自动重写为正确的 url http:server_name/#/product?或如何更改 vue-router 或 vue 配置文件,以便在生产中获得与 locahost 相同的行为?

解决方法

一种可能的客户端解决方法是在生产模式下去掉 None 前缀:

/api