xt-element-ui 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/README.md +201 -0
- package/docs/components/base/xt-button.md +114 -0
- package/docs/components/base/xt-card-item.md +104 -0
- package/docs/components/base/xt-card.md +108 -0
- package/docs/components/base/xt-config-provider.md +199 -0
- package/docs/components/base/xt-flex-box.md +115 -0
- package/docs/components/base/xt-grid-box.md +303 -0
- package/docs/components/base/xt-input.md +150 -0
- package/docs/components/base/xt-text.md +212 -0
- package/docs/components/extend/ex-bar.md +68 -0
- package/docs/components/extend/ex-button.md +62 -0
- package/docs/components/extend/ex-card.md +86 -0
- package/docs/components/extend/ex-chart.md +355 -0
- package/docs/components/extend/ex-icon.md +190 -0
- package/docs/components/extend/ex-line.md +71 -0
- package/docs/components/extend/ex-multi.md +156 -0
- package/docs/components/extend/ex-page.md +75 -0
- package/docs/components/extend/ex-pie.md +70 -0
- package/docs/components/extend/ex-select-tree.md +210 -0
- package/docs/components/extend/ex-table.md +591 -0
- package/docs/components/extend/ex-upload.md +134 -0
- package/docs/components/utils/size.md +148 -0
- package/docs/components/utils/theme.md +183 -0
- package/lib/index.common.js +332 -296
- package/lib/index.css +1 -1
- package/lib/index.umd.js +332 -296
- package/lib/index.umd.min.js +4 -4
- package/package.json +4 -2
- package/src/components/ex-chart/ExMulti.vue +44 -32
- package/src/components/ex-chart/ExPie.vue +5 -4
- package/src/components/ex-chart/index.vue +1 -4
- package/src/components/ex-chart/utils.js +1 -1
- package/src/components/ex-icon/index.js +2 -0
- package/src/components/ex-icon/index.vue +168 -0
- package/src/components/ex-icon/style/index.scss +7 -0
- package/src/components/ex-table/index.vue +3 -3
- package/src/components/index.scss +4 -1
- package/src/components/xt-card-item/images/bar.svg +1 -0
- package/src/components/xt-card-item/images/line.svg +1 -0
- package/src/components/xt-card-item/images/pie.svg +1 -0
- package/src/index.js +3 -0
- package/src/components/ex-chart/ExTrend.vue +0 -124
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
## XtConfigProvider 配置提供者
|
|
2
|
+
|
|
3
|
+
配置提供者组件用于全局配置主题和样式变量。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
::: demo 基本用法
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<XtConfigProvider :theme="theme" proxyElement="body">
|
|
11
|
+
<div>
|
|
12
|
+
<XtButton type="primary" @click="handleSwitchTheme">主题按钮</XtButton>
|
|
13
|
+
</div>
|
|
14
|
+
</XtConfigProvider>
|
|
15
|
+
</template>
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
data(){
|
|
19
|
+
return {
|
|
20
|
+
theme: 'white'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
handleSwitchTheme() {
|
|
25
|
+
this.theme = this.theme == 'dark' ? 'white': 'dark'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
:::
|
|
32
|
+
|
|
33
|
+
## 属性说明
|
|
34
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
35
|
+
|------|------|--------|--------|------|
|
|
36
|
+
| `primaryColor` | String | - | - | 自定义主题色 |
|
|
37
|
+
| `theme` | String | - | `dark`、`light` | 主题模式 |
|
|
38
|
+
| `size` | String | - | `small`、`medium`、`large` | 组件尺寸 |
|
|
39
|
+
| `injectBackground` | Boolean | - | - | 是否注入背景色到根元素 |
|
|
40
|
+
| `injectColor` | Boolean | - | - | 是否注入文字颜色到根元素 |
|
|
41
|
+
| `tag` | String | 'div' | - | 根元素标签 |
|
|
42
|
+
| `proxyElement` | HTMLElement / String | - | - | 代理元素 |
|
|
43
|
+
| `vars` | Object | - | - | 自定义 CSS 变量 |
|
|
44
|
+
|
|
45
|
+
## 示例
|
|
46
|
+
|
|
47
|
+
### 自定义主题色
|
|
48
|
+
|
|
49
|
+
::: demo 自定义主题色
|
|
50
|
+
```vue
|
|
51
|
+
<template>
|
|
52
|
+
<XtConfigProvider :primaryColor="'#722ed1'">
|
|
53
|
+
<div>
|
|
54
|
+
<XtButton type="primary">紫色主题按钮</XtButton>
|
|
55
|
+
<XtCard title="自定义主题卡片">
|
|
56
|
+
<XtText type="primary">主题色文本</XtText>
|
|
57
|
+
</XtCard>
|
|
58
|
+
</div>
|
|
59
|
+
</XtConfigProvider>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
:::
|
|
63
|
+
|
|
64
|
+
### 亮色主题
|
|
65
|
+
|
|
66
|
+
::: demo 亮色主题
|
|
67
|
+
```vue
|
|
68
|
+
<template>
|
|
69
|
+
<XtConfigProvider theme="light" injectBackground>
|
|
70
|
+
<div style="min-height: 100px; padding: 16px;">
|
|
71
|
+
<XtCard title="亮色模式卡片">
|
|
72
|
+
<XtText type="primary">亮色主题内容</XtText>
|
|
73
|
+
</XtCard>
|
|
74
|
+
<XtButton type="primary">亮色主题按钮</XtButton>
|
|
75
|
+
</div>
|
|
76
|
+
</XtConfigProvider>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
### 自定义 CSS 变量
|
|
82
|
+
|
|
83
|
+
::: demo 自定义 CSS 变量
|
|
84
|
+
```vue
|
|
85
|
+
<template>
|
|
86
|
+
<XtConfigProvider :vars="{
|
|
87
|
+
'--xt-color-primary': '#52c41a',
|
|
88
|
+
'--xt-color-success': '#13c2c2',
|
|
89
|
+
'--xt-flex-box-gap': '20px'
|
|
90
|
+
}">
|
|
91
|
+
<XtFlexBox>
|
|
92
|
+
<XtButton type="primary">绿色主题按钮</XtButton>
|
|
93
|
+
<XtButton type="success">青色成功按钮</XtButton>
|
|
94
|
+
</XtFlexBox>
|
|
95
|
+
</XtConfigProvider>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
### 组合配置
|
|
101
|
+
|
|
102
|
+
::: demo 组合配置
|
|
103
|
+
```vue
|
|
104
|
+
<template>
|
|
105
|
+
<XtConfigProvider
|
|
106
|
+
:primaryColor="'#1890ff'"
|
|
107
|
+
size="medium"
|
|
108
|
+
>
|
|
109
|
+
<div style="padding: 16px;">
|
|
110
|
+
<XtCard title="综合配置示例">
|
|
111
|
+
<XtText type="primary">主题色: #1890ff</XtText>
|
|
112
|
+
<XtText type="success">尺寸: medium</XtText>
|
|
113
|
+
</XtCard>
|
|
114
|
+
<XtFlexBox gap="16px" style="margin-top: 16px;">
|
|
115
|
+
<XtButton type="primary">主要按钮</XtButton>
|
|
116
|
+
<XtButton type="success">成功按钮</XtButton>
|
|
117
|
+
<XtButton type="warning">警告按钮</XtButton>
|
|
118
|
+
</XtFlexBox>
|
|
119
|
+
</div>
|
|
120
|
+
</XtConfigProvider>
|
|
121
|
+
</template>
|
|
122
|
+
```
|
|
123
|
+
:::
|
|
124
|
+
|
|
125
|
+
### 动态主题切换
|
|
126
|
+
::: demo 动态主题切换
|
|
127
|
+
```vue
|
|
128
|
+
<template>
|
|
129
|
+
<XtConfigProvider
|
|
130
|
+
:primaryColor="primaryColor"
|
|
131
|
+
:theme="currentTheme"
|
|
132
|
+
injectBackground
|
|
133
|
+
>
|
|
134
|
+
<div style="min-height: 120px; padding: 16px;">
|
|
135
|
+
<XtFlexBox content="space-between" style="margin-bottom: 16px;">
|
|
136
|
+
<span>当前主题: {{ currentTheme }}</span>
|
|
137
|
+
<XtFlexBox gap="8px">
|
|
138
|
+
<XtButton
|
|
139
|
+
type="primary"
|
|
140
|
+
plain
|
|
141
|
+
@click="switchTheme"
|
|
142
|
+
>
|
|
143
|
+
切换主题
|
|
144
|
+
</XtButton>
|
|
145
|
+
<XtButton
|
|
146
|
+
type="success"
|
|
147
|
+
plain
|
|
148
|
+
@click="changeColor"
|
|
149
|
+
>
|
|
150
|
+
更换主题色
|
|
151
|
+
</XtButton>
|
|
152
|
+
</XtFlexBox>
|
|
153
|
+
</XtFlexBox>
|
|
154
|
+
<XtCard title="动态主题示例">
|
|
155
|
+
<XtText type="primary">当前主题色: {{ primaryColor }}</XtText>
|
|
156
|
+
</XtCard>
|
|
157
|
+
</div>
|
|
158
|
+
</XtConfigProvider>
|
|
159
|
+
</template>
|
|
160
|
+
|
|
161
|
+
<script>
|
|
162
|
+
export default {
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
primaryColor: '#1890ff',
|
|
166
|
+
currentTheme: 'light',
|
|
167
|
+
colors: ['#1890ff', '#52c41a', '#faad14', '#f5222d', '#722ed1']
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
methods: {
|
|
171
|
+
switchTheme() {
|
|
172
|
+
this.currentTheme = this.currentTheme === 'light' ? 'dark' : 'light'
|
|
173
|
+
},
|
|
174
|
+
changeColor() {
|
|
175
|
+
const randomIndex = Math.floor(Math.random() * this.colors.length)
|
|
176
|
+
this.primaryColor = this.colors[randomIndex]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
181
|
+
```
|
|
182
|
+
:::
|
|
183
|
+
|
|
184
|
+
## 支持的 CSS 变量
|
|
185
|
+
|
|
186
|
+
| CSS 变量 | 说明 |
|
|
187
|
+
|----------|------|
|
|
188
|
+
| `--xt-color-primary` | 主色 |
|
|
189
|
+
| `--xt-color-success` | 成功色 |
|
|
190
|
+
| `--xt-color-warning` | 警告色 |
|
|
191
|
+
| `--xt-color-danger` | 危险色 |
|
|
192
|
+
| `--xt-color-info` | 信息色 |
|
|
193
|
+
| `--xt-text-color-primary` | 主要文字颜色 |
|
|
194
|
+
| `--xt-text-color-regular` | 常规文字颜色 |
|
|
195
|
+
| `--xt-text-color-secondary` | 次要文字颜色 |
|
|
196
|
+
| `--xt-bg-color` | 背景颜色 |
|
|
197
|
+
| `--xt-bg-color-page` | 页面背景颜色 |
|
|
198
|
+
| `--xt-border-color` | 边框颜色 |
|
|
199
|
+
| `--xt-flex-box-gap` | FlexBox 默认间距 |
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
## XtFlexBox 弹性布局组件
|
|
2
|
+
|
|
3
|
+
弹性布局组件,基于 CSS Flexbox 实现,提供便捷的布局能力。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
::: demo 基本用法
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<XtFlexBox gap="16px">
|
|
11
|
+
<div style="width: 80px; height: 40px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">子元素1</div>
|
|
12
|
+
<div style="width: 80px; height: 40px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">子元素2</div>
|
|
13
|
+
<div style="width: 80px; height: 40px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">子元素3</div>
|
|
14
|
+
</XtFlexBox>
|
|
15
|
+
</template>
|
|
16
|
+
```
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
## 属性说明
|
|
20
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
21
|
+
|------|------|--------|--------|------|
|
|
22
|
+
| `type` | String | flex | - | 布局类型 |
|
|
23
|
+
| `align` | String | center | `start`、`center`、`end`、`stretch`、`baseline` | 交叉轴对齐方式 |
|
|
24
|
+
| `content` | String | start | `start`、`center`、`end`、`between`、`around`、`evenly` | 主轴对齐方式 |
|
|
25
|
+
| `direction` | String | row | `row`、`row-reverse`、`column`、`column-reverse` | 排列方向 |
|
|
26
|
+
| `wrap` | String | unset | `wrap`、`nowrap`、`wrap-reverse` | 是否换行 |
|
|
27
|
+
| `gap` | String | - | - | 子元素间距 |
|
|
28
|
+
|
|
29
|
+
## 示例
|
|
30
|
+
|
|
31
|
+
### 水平居中且两端对齐
|
|
32
|
+
::: demo 水平居中且两端对齐
|
|
33
|
+
```vue
|
|
34
|
+
<template>
|
|
35
|
+
<XtFlexBox content="space-between" align="center">
|
|
36
|
+
<span>左侧内容</span>
|
|
37
|
+
<span>右侧内容</span>
|
|
38
|
+
</XtFlexBox>
|
|
39
|
+
</template>
|
|
40
|
+
```
|
|
41
|
+
:::
|
|
42
|
+
|
|
43
|
+
### 垂直布局
|
|
44
|
+
|
|
45
|
+
::: demo 垂直布局
|
|
46
|
+
```vue
|
|
47
|
+
<template>
|
|
48
|
+
<XtFlexBox direction="column" gap="12px">
|
|
49
|
+
<div style="background: #1890ff; color: white; padding: 8px;">顶部</div>
|
|
50
|
+
<div style="background: #52c41a; color: white; padding: 8px;">中部</div>
|
|
51
|
+
<div style="background: #faad14; color: white; padding: 8px;">底部</div>
|
|
52
|
+
</XtFlexBox>
|
|
53
|
+
</template>
|
|
54
|
+
```
|
|
55
|
+
:::
|
|
56
|
+
|
|
57
|
+
### 均匀分布
|
|
58
|
+
|
|
59
|
+
::: demo 均匀分布
|
|
60
|
+
```vue
|
|
61
|
+
<template>
|
|
62
|
+
<XtFlexBox content="space-around">
|
|
63
|
+
<div style="width: 60px; height: 60px; background: #e6f7ff; border-radius: 8px; display: flex; align-items: center; justify-content: center;">1</div>
|
|
64
|
+
<div style="width: 60px; height: 60px; background: #e6f7ff; border-radius: 8px; display: flex; align-items: center; justify-content: center;">2</div>
|
|
65
|
+
<div style="width: 60px; height: 60px; background: #e6f7ff; border-radius: 8px; display: flex; align-items: center; justify-content: center;">3</div>
|
|
66
|
+
<div style="width: 60px; height: 60px; background: #e6f7ff; border-radius: 8px; display: flex; align-items: center; justify-content: center;">4</div>
|
|
67
|
+
</XtFlexBox>
|
|
68
|
+
</template>
|
|
69
|
+
```
|
|
70
|
+
:::
|
|
71
|
+
|
|
72
|
+
### 自动换行
|
|
73
|
+
|
|
74
|
+
::: demo 自动换行
|
|
75
|
+
```vue
|
|
76
|
+
<template>
|
|
77
|
+
<XtFlexBox wrap="wrap" gap="8px">
|
|
78
|
+
<div v-for="i in 10" :key="i" style="width: 80px; height: 80px; background: #f0f0f0; border-radius: 8px; display: flex; align-items: center; justify-content: center;">{{ i }}</div>
|
|
79
|
+
</XtFlexBox>
|
|
80
|
+
</template>
|
|
81
|
+
```
|
|
82
|
+
:::
|
|
83
|
+
|
|
84
|
+
### 反向排列
|
|
85
|
+
|
|
86
|
+
::: demo 反向排列
|
|
87
|
+
```vue
|
|
88
|
+
<template>
|
|
89
|
+
<XtFlexBox direction="row-reverse">
|
|
90
|
+
<span style="padding: 8px; background: #f5f5f5;">第一</span>
|
|
91
|
+
<span style="padding: 8px; background: #f5f5f5;">第二</span>
|
|
92
|
+
<span style="padding: 8px; background: #f5f5f5;">第三</span>
|
|
93
|
+
</XtFlexBox>
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
:::
|
|
97
|
+
|
|
98
|
+
### 嵌套使用
|
|
99
|
+
|
|
100
|
+
::: demo 嵌套使用
|
|
101
|
+
```vue
|
|
102
|
+
<template>
|
|
103
|
+
<XtFlexBox direction="column" gap="16px">
|
|
104
|
+
<XtFlexBox content="space-between">
|
|
105
|
+
<span>头部左侧</span>
|
|
106
|
+
<span>头部右侧</span>
|
|
107
|
+
</XtFlexBox>
|
|
108
|
+
<XtFlexBox>
|
|
109
|
+
<div style="flex: 1; background: #e6f7ff; padding: 16px;">主内容区</div>
|
|
110
|
+
<div style="width: 200px; background: #f6ffed; padding: 16px;">侧边栏</div>
|
|
111
|
+
</XtFlexBox>
|
|
112
|
+
</XtFlexBox>
|
|
113
|
+
</template>
|
|
114
|
+
```
|
|
115
|
+
:::
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
## XtGridBox 网格布局组件
|
|
2
|
+
|
|
3
|
+
基于 CSS Grid 实现的网格布局组件,提供强大的二维布局能力,支持响应式设计和灵活的配置选项。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
::: demo 基本用法
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<XtGridBox :columns="3" gap="16px">
|
|
11
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目1</div>
|
|
12
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目2</div>
|
|
13
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目3</div>
|
|
14
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目4</div>
|
|
15
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目5</div>
|
|
16
|
+
<div style="padding: 16px; background: #f0f0f0; border-radius: 8px;">项目6</div>
|
|
17
|
+
</XtGridBox>
|
|
18
|
+
</template>
|
|
19
|
+
```
|
|
20
|
+
:::
|
|
21
|
+
|
|
22
|
+
## 属性说明
|
|
23
|
+
|
|
24
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
25
|
+
|------|------|--------|--------|------|
|
|
26
|
+
| `columns` | String / Array / Number | `1fr` | - | 列配置,支持数字、字符串或数组 |
|
|
27
|
+
| `rows` | String / Array | `auto` | - | 行配置 |
|
|
28
|
+
| `gap` | String | - | - | 网格间距(同时控制行和列) |
|
|
29
|
+
| `rowGap` | String | - | - | 行间距 |
|
|
30
|
+
| `colGap` | String | - | - | 列间距 |
|
|
31
|
+
| `flow` | String | `row` | `row`、`column`、`row dense`、`column dense` | 自动排列方向 |
|
|
32
|
+
| `areas` | String / Array | - | - | 命名区域布局 |
|
|
33
|
+
| `align` | String | `stretch` | `start`、`end`、`center`、`stretch`、`baseline` | 子项对齐方式 |
|
|
34
|
+
| `justify` | String | `start` | `start`、`end`、`center`、`space-between`、`space-around`、`space-evenly`、`stretch` | 内容对齐方式 |
|
|
35
|
+
| `responsive` | Object | `{}` | - | 响应式断点配置 |
|
|
36
|
+
|
|
37
|
+
## XtGridItem 子项组件
|
|
38
|
+
|
|
39
|
+
配合 XtGridBox 使用的子项组件,支持跨行跨列等高级布局。
|
|
40
|
+
|
|
41
|
+
### 属性说明
|
|
42
|
+
|
|
43
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
44
|
+
|------|------|--------|--------|------|
|
|
45
|
+
| `span` | Number | `1` | >0 | 跨列数 |
|
|
46
|
+
| `rowSpan` | Number | `1` | >0 | 跨行数 |
|
|
47
|
+
| `start` | Number | `0` | >=0 | 起始列位置 |
|
|
48
|
+
| `rowStart` | Number | `0` | >=0 | 起始行位置 |
|
|
49
|
+
| `area` | String | - | - | 命名区域名称 |
|
|
50
|
+
| `justifySelf` | String | `auto` | `auto`、`start`、`end`、`center`、`stretch` | 水平对齐 |
|
|
51
|
+
| `alignSelf` | String | `auto` | `auto`、`start`、`end`、`center`、`stretch`、`baseline` | 垂直对齐 |
|
|
52
|
+
|
|
53
|
+
## 示例
|
|
54
|
+
|
|
55
|
+
### 基础网格
|
|
56
|
+
|
|
57
|
+
::: demo 基础网格
|
|
58
|
+
```vue
|
|
59
|
+
<template>
|
|
60
|
+
<XtGridBox :columns="4" gap="12px">
|
|
61
|
+
<div v-for="i in 8" :key="i" style="padding: 12px; background: #e6f7ff; border-radius: 4px; text-align: center;">{{ i }}</div>
|
|
62
|
+
</XtGridBox>
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
### 列配置方式
|
|
68
|
+
|
|
69
|
+
::: demo 列配置方式
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<div>
|
|
73
|
+
<!-- 数字方式:自动 repeat -->
|
|
74
|
+
<XtGridBox :columns="3" gap="8px" style="margin-bottom: 16px;">
|
|
75
|
+
<div v-for="i in 3" :key="i" style="padding: 12px; background: #f0f0f0;">{{ i }}</div>
|
|
76
|
+
</XtGridBox>
|
|
77
|
+
|
|
78
|
+
<!-- 字符串方式 -->
|
|
79
|
+
<XtGridBox columns="200px 1fr 1fr" gap="8px" style="margin-bottom: 16px;">
|
|
80
|
+
<div style="padding: 12px; background: #e6f7ff;">固定宽度</div>
|
|
81
|
+
<div style="padding: 12px; background: #f6ffed;">弹性1</div>
|
|
82
|
+
<div style="padding: 12px; background: #fff7e6;">弹性2</div>
|
|
83
|
+
</XtGridBox>
|
|
84
|
+
|
|
85
|
+
<!-- 数组方式 -->
|
|
86
|
+
<XtGridBox :columns="['100px', '1fr', '2fr']" gap="8px">
|
|
87
|
+
<div style="padding: 12px; background: #f9f0ff;">固定</div>
|
|
88
|
+
<div style="padding: 12px; background: #e6fffb;">1份</div>
|
|
89
|
+
<div style="padding: 12px; background: #fff7e6;">2份</div>
|
|
90
|
+
</XtGridBox>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
:::
|
|
95
|
+
|
|
96
|
+
### 跨列跨行
|
|
97
|
+
|
|
98
|
+
::: demo 跨列跨行
|
|
99
|
+
```vue
|
|
100
|
+
<template>
|
|
101
|
+
<XtGridBox :columns="4" gap="12px">
|
|
102
|
+
<XtGridItem :span="2" style="padding: 24px; background: #1890ff; color: white; border-radius: 8px;">跨2列</XtGridItem>
|
|
103
|
+
<XtGridItem style="padding: 24px; background: #52c41a; color: white; border-radius: 8px;">普通</XtGridItem>
|
|
104
|
+
<XtGridItem style="padding: 24px; background: #52c41a; color: white; border-radius: 8px;">普通</XtGridItem>
|
|
105
|
+
<XtGridItem :rowSpan="2" style="padding: 48px 16px; background: #faad14; color: white; border-radius: 8px;">跨2行</XtGridItem>
|
|
106
|
+
<XtGridItem style="padding: 24px; background: #f5222d; color: white; border-radius: 8px;">普通</XtGridItem>
|
|
107
|
+
<XtGridItem style="padding: 24px; background: #f5222d; color: white; border-radius: 8px;">普通</XtGridItem>
|
|
108
|
+
<XtGridItem style="padding: 24px; background: #f5222d; color: white; border-radius: 8px;">普通</XtGridItem>
|
|
109
|
+
</XtGridBox>
|
|
110
|
+
</template>
|
|
111
|
+
```
|
|
112
|
+
:::
|
|
113
|
+
|
|
114
|
+
### 命名区域布局
|
|
115
|
+
|
|
116
|
+
::: demo 命名区域布局
|
|
117
|
+
```vue
|
|
118
|
+
<template>
|
|
119
|
+
<XtGridBox
|
|
120
|
+
:areas="[
|
|
121
|
+
'header header header',
|
|
122
|
+
'sidebar main main',
|
|
123
|
+
'footer footer footer'
|
|
124
|
+
]"
|
|
125
|
+
gap="12px"
|
|
126
|
+
>
|
|
127
|
+
<XtGridItem area="header" style="padding: 16px; background: #1890ff; color: white; border-radius: 8px;">Header</XtGridItem>
|
|
128
|
+
<XtGridItem area="sidebar" style="padding: 16px; background: #52c41a; color: white; border-radius: 8px;">Sidebar</XtGridItem>
|
|
129
|
+
<XtGridItem area="main" style="padding: 16px; background: #faad14; color: white; border-radius: 8px;">Main Content</XtGridItem>
|
|
130
|
+
<XtGridItem area="footer" style="padding: 16px; background: #f5222d; color: white; border-radius: 8px;">Footer</XtGridItem>
|
|
131
|
+
</XtGridBox>
|
|
132
|
+
</template>
|
|
133
|
+
```
|
|
134
|
+
:::
|
|
135
|
+
|
|
136
|
+
### 对齐方式
|
|
137
|
+
|
|
138
|
+
::: demo 对齐方式
|
|
139
|
+
```vue
|
|
140
|
+
<template>
|
|
141
|
+
<div>
|
|
142
|
+
<!-- 子项居中对齐 -->
|
|
143
|
+
<XtGridBox :columns="3" gap="8px" align="center" style="height: 120px; background: #f0f0f0; margin-bottom: 16px;">
|
|
144
|
+
<div style="padding: 8px 16px; background: white;">居中</div>
|
|
145
|
+
<div style="padding: 8px 16px; background: white;">居中</div>
|
|
146
|
+
<div style="padding: 8px 16px; background: white;">居中</div>
|
|
147
|
+
</XtGridBox>
|
|
148
|
+
|
|
149
|
+
<!-- 内容两端对齐 -->
|
|
150
|
+
<XtGridBox :columns="3" gap="8px" justify="space-between" style="background: #f0f0f0;">
|
|
151
|
+
<div style="padding: 8px 16px; background: white;">左</div>
|
|
152
|
+
<div style="padding: 8px 16px; background: white;">中</div>
|
|
153
|
+
<div style="padding: 8px 16px; background: white;">右</div>
|
|
154
|
+
</XtGridBox>
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
157
|
+
```
|
|
158
|
+
:::
|
|
159
|
+
|
|
160
|
+
### 独立间距控制
|
|
161
|
+
|
|
162
|
+
::: demo 独立间距控制
|
|
163
|
+
```vue
|
|
164
|
+
<template>
|
|
165
|
+
<XtGridBox :columns="3" rowGap="24px" colGap="8px">
|
|
166
|
+
<div v-for="i in 6" :key="i" style="padding: 12px; background: #e6f7ff; text-align: center;">{{ i }}</div>
|
|
167
|
+
</XtGridBox>
|
|
168
|
+
</template>
|
|
169
|
+
```
|
|
170
|
+
:::
|
|
171
|
+
|
|
172
|
+
### 自动填充布局
|
|
173
|
+
|
|
174
|
+
::: demo 自动填充布局
|
|
175
|
+
```vue
|
|
176
|
+
<template>
|
|
177
|
+
<XtGridBox columns="repeat(auto-fill, minmax(150px, 1fr))" gap="12px">
|
|
178
|
+
<div v-for="i in 8" :key="i" style="padding: 16px; background: #f0f0f0; text-align: center;">项目{{ i }}</div>
|
|
179
|
+
</XtGridBox>
|
|
180
|
+
</template>
|
|
181
|
+
```
|
|
182
|
+
:::
|
|
183
|
+
|
|
184
|
+
### 嵌套网格
|
|
185
|
+
|
|
186
|
+
::: demo 嵌套网格
|
|
187
|
+
```vue
|
|
188
|
+
<template>
|
|
189
|
+
<XtGridBox :columns="2" gap="16px">
|
|
190
|
+
<!-- 左侧 -->
|
|
191
|
+
<div style="padding: 16px; background: #e6f7ff;">
|
|
192
|
+
<h4>左侧面板</h4>
|
|
193
|
+
<XtGridBox :columns="1" gap="8px">
|
|
194
|
+
<div style="padding: 8px; background: white;">子项1</div>
|
|
195
|
+
<div style="padding: 8px; background: white;">子项2</div>
|
|
196
|
+
</XtGridBox>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<!-- 右侧 -->
|
|
200
|
+
<div style="padding: 16px; background: #f6ffed;">
|
|
201
|
+
<h4>右侧面板</h4>
|
|
202
|
+
<XtGridBox :columns="2" gap="8px">
|
|
203
|
+
<div style="padding: 8px; background: white;">A</div>
|
|
204
|
+
<div style="padding: 8px; background: white;">B</div>
|
|
205
|
+
<div style="padding: 8px; background: white;">C</div>
|
|
206
|
+
<div style="padding: 8px; background: white;">D</div>
|
|
207
|
+
</XtGridBox>
|
|
208
|
+
</div>
|
|
209
|
+
</XtGridBox>
|
|
210
|
+
</template>
|
|
211
|
+
```
|
|
212
|
+
:::
|
|
213
|
+
|
|
214
|
+
## 常见布局问题解决方案
|
|
215
|
+
|
|
216
|
+
### 1. 网格内容溢出
|
|
217
|
+
|
|
218
|
+
**问题**:当网格内容过多时,网格会超出容器边界
|
|
219
|
+
|
|
220
|
+
**解决方案**:
|
|
221
|
+
```vue
|
|
222
|
+
<template>
|
|
223
|
+
<XtGridBox :columns="3" gap="12px" style="min-height: 0;">
|
|
224
|
+
<div style="overflow-y: auto; max-height: 200px;">
|
|
225
|
+
<!-- 大量内容 -->
|
|
226
|
+
</div>
|
|
227
|
+
</XtGridBox>
|
|
228
|
+
</template>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 2. 动态内容高度不一致
|
|
232
|
+
|
|
233
|
+
**问题**:网格子项内容高度不同导致布局错乱
|
|
234
|
+
|
|
235
|
+
**解决方案**:
|
|
236
|
+
```vue
|
|
237
|
+
<template>
|
|
238
|
+
<!-- 使用 align 属性强制对齐 -->
|
|
239
|
+
<XtGridBox :columns="3" gap="12px" align="stretch">
|
|
240
|
+
<div style="display: flex; flex-direction: column;">
|
|
241
|
+
<div style="flex: 1;">内容区域</div>
|
|
242
|
+
<div>固定底部</div>
|
|
243
|
+
</div>
|
|
244
|
+
</XtGridBox>
|
|
245
|
+
</template>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 3. 响应式列数调整
|
|
249
|
+
|
|
250
|
+
**问题**:在不同屏幕尺寸下需要不同的列数
|
|
251
|
+
|
|
252
|
+
**解决方案**:
|
|
253
|
+
```vue
|
|
254
|
+
<template>
|
|
255
|
+
<!-- 使用 CSS 类配合媒体查询 -->
|
|
256
|
+
<XtGridBox class="responsive-grid" gap="12px">
|
|
257
|
+
<div v-for="i in 6" :key="i" style="padding: 12px; background: #f0f0f0;">{{ i }}</div>
|
|
258
|
+
</XtGridBox>
|
|
259
|
+
</template>
|
|
260
|
+
|
|
261
|
+
<style>
|
|
262
|
+
.responsive-grid {
|
|
263
|
+
grid-template-columns: repeat(1, 1fr);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@media (min-width: 576px) {
|
|
267
|
+
.responsive-grid {
|
|
268
|
+
grid-template-columns: repeat(2, 1fr);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@media (min-width: 768px) {
|
|
273
|
+
.responsive-grid {
|
|
274
|
+
grid-template-columns: repeat(3, 1fr);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
</style>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 4. 网格项无法收缩
|
|
281
|
+
|
|
282
|
+
**问题**:当父容器高度受限,子项无法自动收缩
|
|
283
|
+
|
|
284
|
+
**解决方案**:
|
|
285
|
+
```vue
|
|
286
|
+
<template>
|
|
287
|
+
<div style="height: 300px; background: #f0f0f0;">
|
|
288
|
+
<XtGridBox :columns="2" style="height: 100%; min-height: 0;">
|
|
289
|
+
<div style="overflow-y: auto;">
|
|
290
|
+
<!-- 可滚动内容 -->
|
|
291
|
+
</div>
|
|
292
|
+
<div>固定内容</div>
|
|
293
|
+
</XtGridBox>
|
|
294
|
+
</div>
|
|
295
|
+
</template>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 注意事项
|
|
299
|
+
|
|
300
|
+
1. **min-height: 0**:当网格作为子元素嵌套在其他布局中时,建议设置 `min-height: 0` 以确保正确的收缩行为
|
|
301
|
+
2. **响应式设计**:建议配合 CSS 媒体查询实现响应式布局
|
|
302
|
+
3. **性能优化**:对于大量网格项,考虑使用 `flow="dense"` 优化空间利用率
|
|
303
|
+
4. **嵌套使用**:网格可以嵌套使用,但注意控制嵌套层级以避免性能问题
|