[英]Configure VueJS pages (multiple pages in vue.config.js) MPA
I'm making a MPA , using an admin side and a client side.我正在制作MPA ,使用管理端和客户端。
I need to configure the vue.config.js to do that.我需要配置 vue.config.js 来做到这一点。 I found in the documentation that I need to make an object of every page.
我在文档中发现我需要为每个页面创建一个对象。 ( https://cli.vuejs.org/config/#pages ) These are the mines:
( https://cli.vuejs.org/config/#pages ) 这些是地雷:
module.exports = {
pages: {
admin: {
entry: 'src/Admin/main.js',
template: 'public/admin.html',
filename: 'admin.html',
title: 'Admin Page',
chunks: ['chunk-vendors', 'chunk-common', 'admin']
},
index: {
entry: 'src/Client/main.js',
template: 'public/client.html',
filename: 'client.html',
title: 'Client Page',
chunks: ['chunk-vendors', 'chunk-common', 'client']
},
},
}
The problem of that configuration is that Vue takes the "index" as a subpage .该配置的问题在于Vue 将“索引”作为子页面。
I want to access the pages at: localhost:8080/.我想访问位于以下位置的页面:localhost:8080/。 But it only loads client/main.js accessing to localhost:8080/index/
但它只加载访问 localhost:8080/index/ 的 client/main.js
How should I configure the vue.config.js to use one main.js for localhost:8080/ and a diferent one for localhost:8080/admin/我应该如何配置 vue.config.js 以对localhost:8080/使用一个 main.js,对localhost:8080/admin/使用一个不同的 main.js
What is the "title" and "chucks" for?什么是“标题”和“夹头”? I only copy it from the official docs.
我只从官方文档中复制它。
Thanks!
谢谢! I fixed it.
我修好了它。 But now my problem is different.
但现在我的问题不同了。 I can´t access to the sites of the root localhost:8080/.
我无法访问根 localhost:8080/ 的站点。 It need to use the path localhost:8080/index
它需要使用路径 localhost:8080/index
I had the same issue with the regular app not being served at the root and couldn't find anything in the docs.我遇到了相同的问题,没有在根目录提供常规应用程序,并且在文档中找不到任何内容。 When I renamed the
index
page key to some other name though ( client
in the case below), the main app was available at the root: localhost:port/
当我将
index
页键重命名为其他名称(在下面的情况下为client
)时,主应用程序在根目录中可用: localhost:port/
module.exports = {
pages: {
client: {
entry: 'src/Client/main.js',
template: 'public/client.html',
filename: 'client.html',
title: 'Client Page',
chunks: ['chunk-vendors', 'chunk-common', 'client']
},
admin: {
entry: 'src/Admin/main.js',
template: 'public/admin.html',
filename: 'admin.html',
title: 'Admin Page',
chunks: ['chunk-vendors', 'chunk-common', 'admin']
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.