https://element-plus.org/zh-CN/component/container.html
1、安装sass
npm install --save-dev sass
2、找到index.html添加如下style里面的样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
<style>
html,body,#app{
padding: 0px;
margin: 0px;
height: 100%;
box-sizing: border-box;
}
</style>
3、App.vue修改为如下所示
<template>
<router-view/>
</template>
<style lang="scss">
</style>
4、src目录下新建layout目录,并新建Index.vue主页面组件
<template>
<el-container class="layout">
<el-aside width="200px" class="asside">Aside</el-aside>
<el-container>
<el-header class="header">Header</el-header>
<el-main class="main">Main</el-main>
</el-container>
</el-container>
</template>
<style lang="scss">
.layout {
height: 100%;
.asside {
background-color: blueviolet;
}
.header {
background-color: #009688;
}
.main {
background-color: darkcyan;
}
}
</style>
5、在router中引入主页面组件
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/Index.vue'
const routes: Array<RouteRecordRaw> = [
{
path: '/home',
name: 'Home',
component: Layout
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
export default router
6、启动项目
http://localhost:8080/home