我使用 vue.js 和 vue.config.js 方法创建了一个多页应用程序我开发它没有问题我创建了一个生产版本我可以访问主页但是我无法访问其他页面,例如关于我们、投资组合等。
可能是什么问题??以及如何解决?是关于 .htacess 的吗?
这是我的 vue.config.js 代码
module.exports = {
pages: {
index: {
entry: './src/pages/Home/main.js',
template: 'public/index.html',
title: 'Welcome to Appclust',
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
about:{
entry: './src/pages/About/main.js',
template: 'public/index.html',
title: 'About us',
chunks: ['chunk-vendors', 'chunk-common', 'about']
},
portfolio:{
entry: './src/pages/Portfolio/main.js',
template: 'public/index.html',
title: 'Portfolio',
chunks: ['chunk-vendors', 'chunk-common', 'portfolio']
},
testimonials:{
entry: './src/pages/Testimonials/main.js',
template: 'public/index.html',
title: 'Testimonials',
chunks: ['chunk-vendors', 'chunk-common', 'testimonials ']
},
careers:{
entry: './src/pages/Careers/main.js',
template: 'public/index.html',
title: 'Careers',
chunks: ['chunk-vendors', 'chunk-common', 'careers']
},
contact:{
entry: './src/pages/Contact/main.js',
template: 'public/index.html',
title: 'Contact',
chunks: ['chunk-vendors', 'chunk-common', 'contact']
}
}
}
这是我的文件结构生产文件
最佳答案
mode:history
用于 vue-router 中没有 hashbang 的漂亮 URL /about
缺少预期的 index.html。).htaccess
中设置重定向规则对于缺失的路线。 RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# otherwise use history router
RewriteRule ^ /index.html
关于vue.js - 如何部署 Vue.JS MPA(多页面应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62690348/