【发布时间】:2020-11-06 02:52:39
【问题描述】:
我有一个多页 Vue.js 应用程序,其中包含域/法律的工作页面;域/提交;等等。我在 Vue.js 的 pages 的帮助下实现了这一点(即自定义 vue.config.js)
换句话说,我很好地完成了上述工作。
我现在正尝试在新的子目录级别下实现更多的嵌套页面(除了上面我已经拥有的那些)。即
- 域/org/profile1
- 域/org/profile2
- 域/org/profile3
有什么方法可以通过自定义 vue.config.js 来完成这项工作?
当前尝试vue.config.js 代码:
module.exports = {
pages: {
index: {
entry: "./src/pages/home/main.js",
template: "public/index.html",
title: "Home",
chunks: ["chunk-vendors", "chunk-common", "index"],
},
legal: {
entry: "./src/pages/legal/main.js",
template: "public/index.html",
title: "Legal",
chunks: ["chunk-vendors", "chunk-common", "legal"],
},
submit: {
entry: "./src/pages/submit/main.js",
template: "public/index.html",
title: "Submit",
chunks: ["chunk-vendors", "chunk-common", "submit"],
},
org: {
digitalocean: {
entry: "./src/pages/org/digitalocean/main.js",
template: "public/index.html",
title: "Digital Ocean",
chunks: ["chunk-vendors", "chunk-common", "digitalocean"],
},
},
},
};
及文件结构:
src
-assets
-components
-pages
--home
App.vue
main.js
--legal
App.vue
main.js
--submit
App.vue
main.js
--org
---digitalocean
App.vue
main.js
这给了我错误:
Invalid options in vue.config.js: child "pages" fails because [child "org" fails because ["org" must be a string, "org" must be an array, child "entry" fails because ["entry" is required]]]
非常欢迎您提供关于如何通过修改 vue.config.js 使嵌套页面工作的指针!
【问题讨论】:
-
嗯,你不想使用 vue-router?
-
@HimanshuPant 感谢您的参与!如果我不需要使用 vue-router,我想通过仅使用 vue.config.js 来简化它。您认为有什么方法可以实现吗?
-
文档说任何其他属性都传递给 html-webpack-plugin 试试这个 ``` module.exports = { pages: { index: { entry: "./src/pages/home/ main.js",模板:"public/index.html",标题:"Home",块:["chunk-vendors","chunk-common","index"],页面:{ digitalocean: { entry:" ./src/pages/org/digitalocean/main.js”,模板:“public/index.html”,标题:“Digital Ocean”,块:[“chunk-vendors”,“chunk-common”,“digitalocean” ], }, } } }, }; ```
-
感谢您的建议:执行您的建议的错误是:
Invalid options in vue.config.js: child "pages" fails because [child "pages" fails because ["pages" must be a string, "pages" must be an array, child "entry" fails because ["entry" is required]]] -
任何其他指针欢迎@HimanshuPant :)
标签: vue.js vue-cli vue-cli-3 multipage multi-page-application