Skip to content

Commit f40b7f1

Browse files
committed
refactor: 优化代码
1 parent a70c675 commit f40b7f1

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/components/col/src/col.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div
3-
:class="classList"
4-
>
2+
<div :class="classList">
53
<slot />
64
</div>
75
</template>
@@ -39,12 +37,13 @@ export default {
3937
mounted () {
4038
const sizeList = ['xs', 'sm', 'md', 'lg'];
4139
const classList = [];
42-
sizeList.forEach(size => {
43-
if (this[size] && this[size] <= 12) {
44-
classList.push(`layui-col-${size + this[size]}`);
45-
if (this.offset) {
46-
classList.push(`layui-col-${size + '-offset' + this.offset}`);
47-
}
40+
sizeList.forEach(type => {
41+
const val = this[type];
42+
if (val && val <= 12) {
43+
classList.push(`layui-col-${type}${val}`);
44+
}
45+
if (this.offset) {
46+
classList.push(`layui-col-${type}-offset${this.offset}`);
4847
}
4948
});
5049
this.classList = classList;

src/components/row/src/row.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<template>
2-
<div
3-
:class="[
4-
'layui-row',
5-
`layui-col-space${space}`
6-
]"
7-
>
2+
<div :class="[ 'layui-row', `layui-col-space${space}` ]">
83
<slot />
94
</div>
105
</template>

0 commit comments

Comments
 (0)