可以在 vue.config.js 中的 pages 配置中添加一个 entry 属性来指定默认打开的页面。例如:

module.exports = {
  pages: {
    index: {
      entry: 'src/pages/index/main.js',
      template: 'public/index.html',
      filename: 'index.html'
    },
    about: {
      entry: 'src/pages/about/main.js',
      template: 'public/about.html',
      filename: 'about.html'
    }
  },
  devServer: {
    open: 'about' // 默认打开 about.html 页面
  }
}

devServer 配置中,使用 open 属性来指定默认打开的页面,如上例中就是默认打开 about.html 页面。

Vue3.x 多页面应用配置:如何设置默认打开页面

原文地址: https://www.cveoy.top/t/topic/nNPx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录