xt-element-ui 1.3.2 → 1.3.4
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/CHANGELOG.md +72 -72
- package/LICENSE +21 -21
- package/README.md +240 -240
- package/docs/README.md +100 -100
- package/docs/components/base/xt-button.md +114 -114
- package/docs/components/base/xt-card-item.md +104 -104
- package/docs/components/base/xt-card.md +108 -108
- package/docs/components/base/xt-config-provider.md +199 -199
- package/docs/components/base/xt-flex-box.md +115 -115
- package/docs/components/base/xt-grid-box.md +302 -302
- package/docs/components/base/xt-input.md +150 -150
- package/docs/components/base/xt-map-provider.md +23 -0
- package/docs/components/base/xt-map.md +331 -331
- package/docs/components/base/xt-step-price.md +165 -165
- package/docs/components/base/xt-text.md +212 -212
- package/docs/components/base/xt-time.md +165 -165
- package/docs/components/extend/ex-bar.md +67 -67
- package/docs/components/extend/ex-button.md +62 -62
- package/docs/components/extend/ex-card.md +86 -86
- package/docs/components/extend/ex-chart.md +463 -463
- package/docs/components/extend/ex-icon.md +189 -189
- package/docs/components/extend/ex-line.md +70 -70
- package/docs/components/extend/ex-multi.md +155 -155
- package/docs/components/extend/ex-pie.md +69 -69
- package/docs/components/extend/ex-select-tree.md +210 -210
- package/docs/components/extend/ex-table.md +590 -590
- package/docs/components/extend/ex-upload.md +134 -134
- package/docs/components/utils/size.md +147 -147
- package/docs/components/utils/theme.md +182 -182
- package/lib/index.common.js +4131 -4162
- package/lib/index.css +1 -1
- package/lib/index.umd.js +4099 -4129
- package/lib/index.umd.min.js +3 -3
- package/package.json +80 -81
- package/src/components/ex-button/index.js +7 -7
- package/src/components/ex-button/index.vue +66 -66
- package/src/components/ex-button/style/index.scss +67 -67
- package/src/components/ex-card/index.js +7 -7
- package/src/components/ex-card/index.vue +68 -68
- package/src/components/ex-card/style/index.scss +73 -73
- package/src/components/ex-chart/index.js +7 -7
- package/src/components/ex-chart/index.vue +136 -136
- package/src/components/ex-date-picker/index.js +7 -7
- package/src/components/ex-icon/index.js +7 -7
- package/src/components/ex-icon/index.vue +168 -168
- package/src/components/ex-icon/style/index.scss +7 -7
- package/src/components/ex-page/index.js +7 -7
- package/src/components/ex-select-tree/index.js +7 -7
- package/src/components/ex-table/ExTableCell.vue +22 -22
- package/src/components/ex-table/index.js +7 -7
- package/src/components/ex-table/virtualScrollData.js +35 -35
- package/src/components/ex-upload/index.js +7 -7
- package/src/components/index.scss +39 -39
- package/src/components/xt-button/index.js +7 -7
- package/src/components/xt-button/index.vue +97 -97
- package/src/components/xt-card/index.js +7 -7
- package/src/components/xt-card/style/index.scss +48 -48
- package/src/components/xt-card-item/index.js +7 -7
- package/src/components/xt-card-item/style/index copy.scss +71 -71
- package/src/components/xt-card-item/style/index.scss +82 -82
- package/src/components/xt-config-provider/index.js +7 -7
- package/src/components/xt-config-provider/index.vue +362 -362
- package/src/components/xt-config-provider/style/index.scss +11 -11
- package/src/components/xt-flex-box/index.js +7 -7
- package/src/components/xt-flex-box/style/index.scss +81 -81
- package/src/components/xt-grid-box/index.js +7 -7
- package/src/components/xt-grid-box/style/index.scss +92 -92
- package/src/components/xt-grid-item/index.js +7 -7
- package/src/components/xt-grid-item/index.vue +106 -106
- package/src/components/xt-input/index.js +7 -7
- package/src/components/xt-input/index.vue +66 -66
- package/src/components/xt-input/style/index.scss +84 -84
- package/src/components/xt-map/adapters/amap.js +235 -235
- package/src/components/xt-map/adapters/baidu.js +254 -254
- package/src/components/xt-map/adapters/base.js +267 -267
- package/src/components/xt-map/adapters/index.js +29 -29
- package/src/components/xt-map/adapters/tianditu.js +242 -242
- package/src/components/xt-map/config/xt-map-config.js +197 -197
- package/src/components/xt-map/index.js +8 -30
- package/src/components/xt-map/index.vue +351 -351
- package/src/components/xt-map/loaders/script-loader.js +114 -114
- package/src/components/xt-map/provider.vue +200 -200
- package/src/components/xt-map/style/index.scss +77 -77
- package/src/components/xt-map-provider/index.js +8 -0
- package/src/components/xt-step-price/index.js +10 -10
- package/src/components/xt-step-price/index.vue +272 -272
- package/src/components/xt-step-price/style/index.scss +123 -123
- package/src/components/xt-step-price-item/index.js +7 -7
- package/src/components/xt-step-price-item/index.vue +187 -187
- package/src/components/xt-text/index.js +7 -7
- package/src/components/xt-text/index.vue +1 -1
- package/src/components/xt-text/style/index.scss +92 -92
- package/src/components/xt-time/index.js +7 -7
- package/src/components/xt-time/index.vue +313 -313
- package/src/components/xt-time/style/index.scss +23 -23
- package/src/config/element-registry.js +135 -135
- package/src/index.js +162 -178
- package/src/styles/css-variables.scss +257 -257
- package/src/styles/theme/background.scss +5 -5
- package/src/styles/theme/border-radius.scss +3 -3
- package/src/styles/theme/borders.scss +3 -3
- package/src/styles/theme/colors.scss +101 -101
- package/src/styles/theme/component-variables.scss +69 -69
- package/src/styles/theme/dark-variables.scss +28 -28
- package/src/styles/theme/font.scss +12 -12
- package/src/styles/theme/index.scss +11 -11
- package/src/styles/theme/shadows.scss +2 -2
- package/src/styles/theme/spacing.scss +4 -4
- package/src/styles/theme/transitions.scss +2 -2
- package/src/styles/theme/typography.scss +4 -4
- package/src/styles/variables-export.scss +85 -85
- package/src/utils/index.js +191 -202
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
## ExUpload 图片上传
|
|
2
|
-
|
|
3
|
-
基于 ElementUI `el-upload` 封装,支持图片上传、预览、删除,以及多图管理。
|
|
4
|
-
|
|
5
|
-
## 基础用法
|
|
6
|
-
|
|
7
|
-
设置 `action` 为上传接口路径,`base-url` 为图片基础地址,`v-model` 绑定逗号分隔的图片路径字符串:
|
|
8
|
-
|
|
9
|
-
::: demo 图片上传基础示例
|
|
10
|
-
```vue
|
|
11
|
-
<template>
|
|
12
|
-
<ex-upload
|
|
13
|
-
v-model="imgList"
|
|
14
|
-
action="/api/upload"
|
|
15
|
-
base-url="https://example.com"
|
|
16
|
-
/>
|
|
17
|
-
</template>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
export default {
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
imgList: ''
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
```
|
|
29
|
-
:::
|
|
30
|
-
|
|
31
|
-
## 多图上传
|
|
32
|
-
|
|
33
|
-
设置 `multiple` 开启多图上传,通过 `limit` 限制最多上传数量:
|
|
34
|
-
|
|
35
|
-
::: demo 多图上传示例
|
|
36
|
-
```vue
|
|
37
|
-
<template>
|
|
38
|
-
<ex-upload
|
|
39
|
-
v-model="imgList"
|
|
40
|
-
action="/api/upload"
|
|
41
|
-
base-url="https://example.com"
|
|
42
|
-
multiple
|
|
43
|
-
:limit="5"
|
|
44
|
-
/>
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<script>
|
|
48
|
-
export default {
|
|
49
|
-
data() {
|
|
50
|
-
return {
|
|
51
|
-
imgList: ''
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
</script>
|
|
56
|
-
```
|
|
57
|
-
:::
|
|
58
|
-
|
|
59
|
-
## 图片大小
|
|
60
|
-
|
|
61
|
-
通过 `size` 属性设置显示尺寸:
|
|
62
|
-
|
|
63
|
-
::: demo 图片尺寸示例
|
|
64
|
-
```vue
|
|
65
|
-
<template>
|
|
66
|
-
<div>
|
|
67
|
-
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" />
|
|
68
|
-
<div style="margin-top: 20px">
|
|
69
|
-
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" size="big" />
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</template>
|
|
73
|
-
|
|
74
|
-
<script>
|
|
75
|
-
export default {
|
|
76
|
-
data() {
|
|
77
|
-
return {
|
|
78
|
-
img: ''
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
```
|
|
84
|
-
:::
|
|
85
|
-
|
|
86
|
-
## 禁用状态
|
|
87
|
-
|
|
88
|
-
`disabled` 属性可禁用上传和删除功能:
|
|
89
|
-
|
|
90
|
-
::: demo 禁用上传示例
|
|
91
|
-
```vue
|
|
92
|
-
<template>
|
|
93
|
-
<ex-upload
|
|
94
|
-
v-model="img"
|
|
95
|
-
action="/api/upload"
|
|
96
|
-
base-url="https://example.com"
|
|
97
|
-
disabled
|
|
98
|
-
/>
|
|
99
|
-
</template>
|
|
100
|
-
|
|
101
|
-
<script>
|
|
102
|
-
export default {
|
|
103
|
-
data() {
|
|
104
|
-
return {
|
|
105
|
-
img: 'demo.jpg'
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
</script>
|
|
110
|
-
```
|
|
111
|
-
:::
|
|
112
|
-
|
|
113
|
-
## Attributes
|
|
114
|
-
|
|
115
|
-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
116
|
-
|------|------|------|--------|--------|
|
|
117
|
-
| src | 当前图片列表,以英文逗号分隔(v-model) | string | — | '' |
|
|
118
|
-
| action | 上传接口路径,与 base-url 拼接 | string | — | '' |
|
|
119
|
-
| base-url | 图片基础地址(服务端域名) | string | — | '' |
|
|
120
|
-
| multiple | 是否支持多选 | boolean | — | false |
|
|
121
|
-
| limit | 最多上传数量 | number | — | 5 |
|
|
122
|
-
| accept | 允许的文件类型 | string | — | .jpg,.jpeg,.png |
|
|
123
|
-
| auto-upload | 是否在选取文件后立即上传 | boolean | — | true |
|
|
124
|
-
| disabled | 是否禁用 | boolean | — | false |
|
|
125
|
-
| size | 图片展示尺寸 | string | big | — |
|
|
126
|
-
| data | 上传时附带的额外参数 | object | — | {} |
|
|
127
|
-
| all-file-list | 用于图库预览的图片列表 | array | — | — |
|
|
128
|
-
| before-emit-data | 对上传结果进行处理的回调函数,返回 `false` 代表上传失败 | function(res, file, type) | — | (内部函数) |
|
|
129
|
-
|
|
130
|
-
## Events
|
|
131
|
-
|
|
132
|
-
| 事件名 | 说明 | 回调参数 |
|
|
133
|
-
|--------|------|----------|
|
|
134
|
-
| change | 图片列表变化时触发 | 以英文逗号分隔的图片路径字符串 |
|
|
1
|
+
## ExUpload 图片上传
|
|
2
|
+
|
|
3
|
+
基于 ElementUI `el-upload` 封装,支持图片上传、预览、删除,以及多图管理。
|
|
4
|
+
|
|
5
|
+
## 基础用法
|
|
6
|
+
|
|
7
|
+
设置 `action` 为上传接口路径,`base-url` 为图片基础地址,`v-model` 绑定逗号分隔的图片路径字符串:
|
|
8
|
+
|
|
9
|
+
::: demo 图片上传基础示例
|
|
10
|
+
```vue
|
|
11
|
+
<template>
|
|
12
|
+
<ex-upload
|
|
13
|
+
v-model="imgList"
|
|
14
|
+
action="/api/upload"
|
|
15
|
+
base-url="https://example.com"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
imgList: ''
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
## 多图上传
|
|
32
|
+
|
|
33
|
+
设置 `multiple` 开启多图上传,通过 `limit` 限制最多上传数量:
|
|
34
|
+
|
|
35
|
+
::: demo 多图上传示例
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<ex-upload
|
|
39
|
+
v-model="imgList"
|
|
40
|
+
action="/api/upload"
|
|
41
|
+
base-url="https://example.com"
|
|
42
|
+
multiple
|
|
43
|
+
:limit="5"
|
|
44
|
+
/>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
export default {
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
imgList: ''
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
:::
|
|
58
|
+
|
|
59
|
+
## 图片大小
|
|
60
|
+
|
|
61
|
+
通过 `size` 属性设置显示尺寸:
|
|
62
|
+
|
|
63
|
+
::: demo 图片尺寸示例
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<div>
|
|
67
|
+
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" />
|
|
68
|
+
<div style="margin-top: 20px">
|
|
69
|
+
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" size="big" />
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
export default {
|
|
76
|
+
data() {
|
|
77
|
+
return {
|
|
78
|
+
img: ''
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
:::
|
|
85
|
+
|
|
86
|
+
## 禁用状态
|
|
87
|
+
|
|
88
|
+
`disabled` 属性可禁用上传和删除功能:
|
|
89
|
+
|
|
90
|
+
::: demo 禁用上传示例
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<ex-upload
|
|
94
|
+
v-model="img"
|
|
95
|
+
action="/api/upload"
|
|
96
|
+
base-url="https://example.com"
|
|
97
|
+
disabled
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
export default {
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
img: 'demo.jpg'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
</script>
|
|
110
|
+
```
|
|
111
|
+
:::
|
|
112
|
+
|
|
113
|
+
## Attributes
|
|
114
|
+
|
|
115
|
+
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
116
|
+
|------|------|------|--------|--------|
|
|
117
|
+
| src | 当前图片列表,以英文逗号分隔(v-model) | string | — | '' |
|
|
118
|
+
| action | 上传接口路径,与 base-url 拼接 | string | — | '' |
|
|
119
|
+
| base-url | 图片基础地址(服务端域名) | string | — | '' |
|
|
120
|
+
| multiple | 是否支持多选 | boolean | — | false |
|
|
121
|
+
| limit | 最多上传数量 | number | — | 5 |
|
|
122
|
+
| accept | 允许的文件类型 | string | — | .jpg,.jpeg,.png |
|
|
123
|
+
| auto-upload | 是否在选取文件后立即上传 | boolean | — | true |
|
|
124
|
+
| disabled | 是否禁用 | boolean | — | false |
|
|
125
|
+
| size | 图片展示尺寸 | string | big | — |
|
|
126
|
+
| data | 上传时附带的额外参数 | object | — | {} |
|
|
127
|
+
| all-file-list | 用于图库预览的图片列表 | array | — | — |
|
|
128
|
+
| before-emit-data | 对上传结果进行处理的回调函数,返回 `false` 代表上传失败 | function(res, file, type) | — | (内部函数) |
|
|
129
|
+
|
|
130
|
+
## Events
|
|
131
|
+
|
|
132
|
+
| 事件名 | 说明 | 回调参数 |
|
|
133
|
+
|--------|------|----------|
|
|
134
|
+
| change | 图片列表变化时触发 | 以英文逗号分隔的图片路径字符串 |
|
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
## 字体大小配置
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
通过工具函数可以全局设置组件的字体大小,支持三种预设尺寸:`small`、`medium`、`large`。
|
|
6
|
-
|
|
7
|
-
## 方法说明
|
|
8
|
-
|
|
9
|
-
### setSize(size)
|
|
10
|
-
|
|
11
|
-
设置全局字体大小。
|
|
12
|
-
|
|
13
|
-
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
-
|------|------|------|------|
|
|
15
|
-
| `size` | String | 是 | 字体大小:`small`、`medium`、`large` |
|
|
16
|
-
|
|
17
|
-
```vue
|
|
18
|
-
<template>
|
|
19
|
-
<div>
|
|
20
|
-
<XtButton @click="setSmall">小号字体</XtButton>
|
|
21
|
-
<XtButton @click="setMedium">中号字体</XtButton>
|
|
22
|
-
<XtButton @click="setLarge">大号字体</XtButton>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script>
|
|
27
|
-
import { setSize } from 'xt-element-ui'
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
methods: {
|
|
31
|
-
setSmall() {
|
|
32
|
-
setSize('small')
|
|
33
|
-
},
|
|
34
|
-
setMedium() {
|
|
35
|
-
setSize('medium')
|
|
36
|
-
},
|
|
37
|
-
setLarge() {
|
|
38
|
-
setSize('large')
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
</script>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### getSize()
|
|
46
|
-
|
|
47
|
-
获取当前字体大小配置。
|
|
48
|
-
|
|
49
|
-
```vue
|
|
50
|
-
<template>
|
|
51
|
-
<div>
|
|
52
|
-
<XtText>当前字体大小:{{ currentSize }}</XtText>
|
|
53
|
-
</div>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<script>
|
|
57
|
-
import { getSize } from 'xt-element-ui'
|
|
58
|
-
|
|
59
|
-
export default {
|
|
60
|
-
computed: {
|
|
61
|
-
currentSize() {
|
|
62
|
-
return getSize()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
</script>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## 字体大小对照表
|
|
70
|
-
|
|
71
|
-
| 尺寸 | 说明 |
|
|
72
|
-
|------|------|
|
|
73
|
-
| `small` | 小号字体,默认值 |
|
|
74
|
-
| `medium` | 中号字体 |
|
|
75
|
-
| `large` | 大号字体,适合大屏展示 |
|
|
76
|
-
|
|
77
|
-
## 使用示例
|
|
78
|
-
|
|
79
|
-
### 在组件安装时配置
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
import XtElementUI from 'xt-element-ui'
|
|
83
|
-
|
|
84
|
-
Vue.use(XtElementUI, {
|
|
85
|
-
size: 'large' // 全局设置大号字体
|
|
86
|
-
})
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 动态切换字体大小
|
|
90
|
-
|
|
91
|
-
```vue
|
|
92
|
-
<template>
|
|
93
|
-
<div>
|
|
94
|
-
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
95
|
-
<XtButton
|
|
96
|
-
v-for="size in sizes"
|
|
97
|
-
:key="size"
|
|
98
|
-
:type="currentSize === size ? 'primary' : ''"
|
|
99
|
-
@click="changeSize(size)"
|
|
100
|
-
>
|
|
101
|
-
{{ sizeLabels[size] }}
|
|
102
|
-
</XtButton>
|
|
103
|
-
</XtFlexBox>
|
|
104
|
-
|
|
105
|
-
<XtCard>
|
|
106
|
-
<XtCardItem title="当前尺寸">
|
|
107
|
-
<XtText type="primary" bold>{{ currentSize }}</XtText>
|
|
108
|
-
</XtCardItem>
|
|
109
|
-
<XtCardItem title="示例文本">
|
|
110
|
-
<XtText>这是一段示例文本,用于展示字体大小效果。</XtText>
|
|
111
|
-
</XtCardItem>
|
|
112
|
-
</XtCard>
|
|
113
|
-
</div>
|
|
114
|
-
</template>
|
|
115
|
-
|
|
116
|
-
<script>
|
|
117
|
-
import { setSize, getSize } from 'xt-element-ui'
|
|
118
|
-
|
|
119
|
-
export default {
|
|
120
|
-
data() {
|
|
121
|
-
return {
|
|
122
|
-
sizes: ['small', 'medium', 'large'],
|
|
123
|
-
sizeLabels: {
|
|
124
|
-
small: '小号',
|
|
125
|
-
medium: '中号',
|
|
126
|
-
large: '大号'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
computed: {
|
|
131
|
-
currentSize() {
|
|
132
|
-
return getSize()
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
methods: {
|
|
136
|
-
changeSize(size) {
|
|
137
|
-
setSize(size)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
</script>
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 注意事项
|
|
145
|
-
|
|
146
|
-
1. 字体大小设置会影响所有使用组件库样式的元素
|
|
147
|
-
2. 设置后会在 `html` 标签上添加 `data-size` 属性
|
|
1
|
+
## 字体大小配置
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
通过工具函数可以全局设置组件的字体大小,支持三种预设尺寸:`small`、`medium`、`large`。
|
|
6
|
+
|
|
7
|
+
## 方法说明
|
|
8
|
+
|
|
9
|
+
### setSize(size)
|
|
10
|
+
|
|
11
|
+
设置全局字体大小。
|
|
12
|
+
|
|
13
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
+
|------|------|------|------|
|
|
15
|
+
| `size` | String | 是 | 字体大小:`small`、`medium`、`large` |
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<XtButton @click="setSmall">小号字体</XtButton>
|
|
21
|
+
<XtButton @click="setMedium">中号字体</XtButton>
|
|
22
|
+
<XtButton @click="setLarge">大号字体</XtButton>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import { setSize } from 'xt-element-ui'
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
methods: {
|
|
31
|
+
setSmall() {
|
|
32
|
+
setSize('small')
|
|
33
|
+
},
|
|
34
|
+
setMedium() {
|
|
35
|
+
setSize('medium')
|
|
36
|
+
},
|
|
37
|
+
setLarge() {
|
|
38
|
+
setSize('large')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### getSize()
|
|
46
|
+
|
|
47
|
+
获取当前字体大小配置。
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<template>
|
|
51
|
+
<div>
|
|
52
|
+
<XtText>当前字体大小:{{ currentSize }}</XtText>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
import { getSize } from 'xt-element-ui'
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
computed: {
|
|
61
|
+
currentSize() {
|
|
62
|
+
return getSize()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 字体大小对照表
|
|
70
|
+
|
|
71
|
+
| 尺寸 | 说明 |
|
|
72
|
+
|------|------|
|
|
73
|
+
| `small` | 小号字体,默认值 |
|
|
74
|
+
| `medium` | 中号字体 |
|
|
75
|
+
| `large` | 大号字体,适合大屏展示 |
|
|
76
|
+
|
|
77
|
+
## 使用示例
|
|
78
|
+
|
|
79
|
+
### 在组件安装时配置
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import XtElementUI from 'xt-element-ui'
|
|
83
|
+
|
|
84
|
+
Vue.use(XtElementUI, {
|
|
85
|
+
size: 'large' // 全局设置大号字体
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 动态切换字体大小
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<div>
|
|
94
|
+
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
95
|
+
<XtButton
|
|
96
|
+
v-for="size in sizes"
|
|
97
|
+
:key="size"
|
|
98
|
+
:type="currentSize === size ? 'primary' : ''"
|
|
99
|
+
@click="changeSize(size)"
|
|
100
|
+
>
|
|
101
|
+
{{ sizeLabels[size] }}
|
|
102
|
+
</XtButton>
|
|
103
|
+
</XtFlexBox>
|
|
104
|
+
|
|
105
|
+
<XtCard>
|
|
106
|
+
<XtCardItem title="当前尺寸">
|
|
107
|
+
<XtText type="primary" bold>{{ currentSize }}</XtText>
|
|
108
|
+
</XtCardItem>
|
|
109
|
+
<XtCardItem title="示例文本">
|
|
110
|
+
<XtText>这是一段示例文本,用于展示字体大小效果。</XtText>
|
|
111
|
+
</XtCardItem>
|
|
112
|
+
</XtCard>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script>
|
|
117
|
+
import { setSize, getSize } from 'xt-element-ui'
|
|
118
|
+
|
|
119
|
+
export default {
|
|
120
|
+
data() {
|
|
121
|
+
return {
|
|
122
|
+
sizes: ['small', 'medium', 'large'],
|
|
123
|
+
sizeLabels: {
|
|
124
|
+
small: '小号',
|
|
125
|
+
medium: '中号',
|
|
126
|
+
large: '大号'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
computed: {
|
|
131
|
+
currentSize() {
|
|
132
|
+
return getSize()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
methods: {
|
|
136
|
+
changeSize(size) {
|
|
137
|
+
setSize(size)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 注意事项
|
|
145
|
+
|
|
146
|
+
1. 字体大小设置会影响所有使用组件库样式的元素
|
|
147
|
+
2. 设置后会在 `html` 标签上添加 `data-size` 属性
|
|
148
148
|
3. 需要配合对应的 CSS 样式才能生效
|