vue3 多页面配置
时间: 2023-08-12 08:24:06 浏览: 53
在 Vue3 中,多页面配置可以通过配置 `vue.config.js` 文件实现。以下是一个简单的多页面配置示例:
```javascript
module.exports = {
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html',
title: 'Index Page',
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
about: {
entry: 'src/about.js',
template: 'public/about.html',
filename: 'about.html',
title: 'About Page',
chunks: ['chunk-vendors', 'chunk-common', 'about']
}
}
}
```
在上面的示例中,我们定义了两个页面:`index` 和 `about`。每个页面都有不同的入口文件、模板文件、输出文件名和页面标题。`chunks` 属性指定了页面所需的代码块。
在代码中,可以使用 `process.env.NODE_ENV` 来区分不同的环境,例如:
```javascript
if (process.env.NODE_ENV === 'production') {
// 生产环境
} else {
// 开发环境
}
```
以上就是一个简单的 Vue3 多页面配置的实现方式,希望对你有所帮助。