前端vue
后端nginx
假如项目根目录设定为/web/services
http://example.com/web/services/user/:user_id
router/index.js设置
import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import download from '@/components/download'
Vue.use(Router)
export default new Router({
base:'/web/services/',
mode:'history',
routes: [
{
path:'/',
component:index,
},
{
path:'/user/:user_id/download',
component:download
}
]
})
config/index.js设置
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/web/services/',//*************主要是这里********
/**
* Source Maps
*/
index.html(不确定是否重要)
<meta base="/web/services/">
这些都是前端的配置,
后端nginx的配置参考https://blog.csdn.net/youyudexiaowangzi/article/details/102599882