在网上找了很久发现网上例子用起来,实现不了,so
首先看下我nginx的目录,我所有vue项目就是放在demo下的
接下来先来配置vue项目,在router下的index中这样子配置
export default new Router({
mode:'history',
base:'/ybr/',//这里是你在nginx中demo下的项目存放文件夹名称
routes: [
{},
{},
]
})
然后配置config文件夹下的index.js
module.exports = {
baseurl:'/ybr',//这里需要给baseurl一个路径就是你域名后面的地址
build: {
...
},
dev: {
...
},
}
配置nginx的nginx.conf,先来看下我目录,由于我跑的项目比较多,所以我把server的配置配到了vhost下面的index.conf的文件里面了
其中nginx.conf中把server注释了,在http{}里面增加include E:/nginx-1.14.0/conf/vhost/*.conf;引入server配置
加下来看我index.conf的配置