如何部署Vue.JS MPA(多页应用程序)
我使用vue.js和vue.config.js方法创建了一个多页面应用程序,我开发它时没有遇到任何问题,我创建了一个生产版本,我可以访问主页,但我无法访问其他页面,如关于我们、公文包等 有什么问题吗??如何解决呢?是关于.htacess的吗 这是我的vue.config.js代码如何部署Vue.JS MPA(多页应用程序),vue.js,vue-component,vue-router,vuejs-routing,Vue.js,Vue Component,Vue Router,Vuejs Routing,我使用vue.js和vue.config.js方法创建了一个多页面应用程序,我开发它时没有遇到任何问题,我创建了一个生产版本,我可以访问主页,但我无法访问其他页面,如关于我们、公文包等 有什么问题吗??如何解决呢?是关于.htacess的吗 这是我的vue.config.js代码 module.exports = { pages: { index: { entry: './src/pages/Home/main.js', template: '
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']
}
}
}
这是我的文件结构
生产文件
模式:历史记录,而不使用hashbang
/about
缺少预期的index.html).htaccess
中为丢失的路由设置重定向规则对于像多页这样的任务,我建议使用nuxt而不是vue CLI。你知道吗?将.htaccess做这项工作吗?是的,它应该做这项工作。以前用AngularJS解决了共享主机我应该复制粘贴相同的东西吗??我是说你给了我什么??或者我应该做一些修改吗??我复制粘贴了同样的东西,但无论我点击哪个页面,它都会转到主页或索引页。我删除了这一行“#否则使用历史路由器重写规则^/index.html”,然后在尝试导航到其他路径时出错pages@BeingMR.G可能会有一些变化,在这里您可以参考更多关于Vue历史记录模式的信息:您可以使用Vue meta作为动态关键字、描述和标题等。它也与NUXT和Vue兼容。如果解决了,请在答案上打绿色勾:)干杯
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