廢話不說 ;直接代碼
nginx.conf
html
server {
listen 80;
server_name localhost;
vue
#charset koi8-r; #access_log logs/host.access.log main; location / { root /hantai/file; autoindex on; autoindex_exact_size off; autoindex_localtime on; } location /h3s { alias /hantai/file/h3s/; index index.html /h3s/index.html; try_files $uri $uri/ /h3s/index.html; } ... } vue-router const router = createRouter({
// history: createWebHashHistory(),
history: createWebHistory('/h3s/'),
//本身服務器的文件夾名 這裏是 www.baidu.com/h3s/
routes
});
router.beforeEach((to, from, next) => {
console.log('beforeEach');
if (to.matched[0].props.default.title) {
document.title =to.matched[0].props.default.title
}
next()
})
nginx
vue.config.js module.exports = { publicPath: '/h3s/',
...
}
vue-router