Vue CLI 页面配置:如何设置默认打开页面
在使用 Vue CLI 创建多页面应用时,pages 配置选项用于定义每个页面的配置信息,包括入口文件、模板文件、输出文件名以及依赖的 chunk。如果默认情况下无法打开 reception 页面,可能是因为 backstage 页面配置在 reception 页面前面,导致 backstage 页面被设置为默认页面。
为了让 reception 页面作为默认页面,可以将它配置在 pages 对象中的第一个位置:
pages: {
reception: {
entry: 'src/pages/reception/main.js',
template: 'src/pages/reception/reception.html',
fileName: 'index.html',
chunks: ['chunk-vendors', 'chunk-common', 'reception'],
},
backstage: {
entry: 'src/pages/backstage/main.js',
template: 'src/pages/backstage/backstage.html',
fileName: 'backstage.html',
chunks: ['chunk-vendors', 'chunk-common', 'backstage'],
},
},
这样,访问根路径时就会打开 reception 页面。如果你需要保留 backstage 页面,可以手动访问它的 URL,比如 http://localhost:8080/backstage.html。
原文地址: https://www.cveoy.top/t/topic/nNOS 著作权归作者所有。请勿转载和采集!