Vue、Element-UI 入门

插件安装

直接使用 IDEA 新建 Vue 项目

安装 Element-UI

1
npm i element-ui -S

配置 Element-UI

config-element-ui.png

安装 ESLint (可选)

1
eslint --init

ESLint-init.png

组件复用

新建组件 MyComponent

new-component.png

编写相关代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<el-container>
<el-header>{{ header }}</el-header>
<el-container>
<el-aside width="200px">{{ aside }}</el-aside>
<el-main>{{ main }}</el-main>
</el-container>
<el-footer>{{ footer }}</el-footer>
</el-container>
</template>

<script>
export default {
name: "MyComponent",
props: {
header: String,
aside: String,
main: String,
footer: String,
},
};
</script>

<style scoped>
.el-header,
.el-footer {
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
}

.el-aside {
background-color: #d3dce6;
color: #333;
text-align: center;
line-height: 200px;
}

.el-main {
background-color: #e9eef3;
color: #333;
text-align: center;
line-height: 160px;
}

body > .el-container {
margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
line-height: 320px;
}
</style>

复用组件

reuse-component.png

全局组件

global-component.png


Vue、Element-UI 入门
https://blog.josway.cc/2022/04/25/yuque/Vue、Element-UI 入门/
作者
JOSWAY
发布于
2022年4月25日
许可协议