@fredwsw/frontend-rules 1.0.0

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.
Files changed (81) hide show
  1. package/README.md +302 -0
  2. package/bin/cli.js +155 -0
  3. package/package.json +22 -0
  4. package/template/docs/uv-ui-docs/action-sheet-cn.md +180 -0
  5. package/template/docs/uv-ui-docs/album-cn.md +104 -0
  6. package/template/docs/uv-ui-docs/alert-cn.md +71 -0
  7. package/template/docs/uv-ui-docs/avatar-cn.md +149 -0
  8. package/template/docs/uv-ui-docs/back-top-cn.md +121 -0
  9. package/template/docs/uv-ui-docs/badge-cn.md +100 -0
  10. package/template/docs/uv-ui-docs/button-cn.md +181 -0
  11. package/template/docs/uv-ui-docs/calendar-cn.md +179 -0
  12. package/template/docs/uv-ui-docs/calendars-cn.md +264 -0
  13. package/template/docs/uv-ui-docs/cell-cn.md +163 -0
  14. package/template/docs/uv-ui-docs/checkbox-cn.md +164 -0
  15. package/template/docs/uv-ui-docs/code-cn.md +122 -0
  16. package/template/docs/uv-ui-docs/code-input-cn.md +127 -0
  17. package/template/docs/uv-ui-docs/collapse-cn.md +206 -0
  18. package/template/docs/uv-ui-docs/color-cn.md +122 -0
  19. package/template/docs/uv-ui-docs/count-down-cn.md +169 -0
  20. package/template/docs/uv-ui-docs/count-to-cn.md +125 -0
  21. package/template/docs/uv-ui-docs/datetime-picker-cn.md +167 -0
  22. package/template/docs/uv-ui-docs/divider-cn.md +90 -0
  23. package/template/docs/uv-ui-docs/drop-down-cn.md +287 -0
  24. package/template/docs/uv-ui-docs/empty-cn.md +76 -0
  25. package/template/docs/uv-ui-docs/form-cn.md +220 -0
  26. package/template/docs/uv-ui-docs/gap-cn.md +63 -0
  27. package/template/docs/uv-ui-docs/grid-cn.md +187 -0
  28. package/template/docs/uv-ui-docs/icon-cn.md +255 -0
  29. package/template/docs/uv-ui-docs/image-cn.md +170 -0
  30. package/template/docs/uv-ui-docs/index-list-cn.md +132 -0
  31. package/template/docs/uv-ui-docs/input-cn.md +157 -0
  32. package/template/docs/uv-ui-docs/keyboard-cn.md +156 -0
  33. package/template/docs/uv-ui-docs/layout-cn.md +215 -0
  34. package/template/docs/uv-ui-docs/line-cn.md +77 -0
  35. package/template/docs/uv-ui-docs/line-progress-cn.md +132 -0
  36. package/template/docs/uv-ui-docs/link-cn.md +97 -0
  37. package/template/docs/uv-ui-docs/list-cn.md +185 -0
  38. package/template/docs/uv-ui-docs/load-more-cn.md +144 -0
  39. package/template/docs/uv-ui-docs/loading-icon-cn.md +125 -0
  40. package/template/docs/uv-ui-docs/loading-page-cn.md +85 -0
  41. package/template/docs/uv-ui-docs/modal-cn.md +212 -0
  42. package/template/docs/uv-ui-docs/navbar-cn.md +171 -0
  43. package/template/docs/uv-ui-docs/no-network-cn.md +112 -0
  44. package/template/docs/uv-ui-docs/notice-bar-cn.md +119 -0
  45. package/template/docs/uv-ui-docs/notify-cn.md +185 -0
  46. package/template/docs/uv-ui-docs/number-box-cn.md +131 -0
  47. package/template/docs/uv-ui-docs/overlay-cn.md +122 -0
  48. package/template/docs/uv-ui-docs/parse-cn.md +177 -0
  49. package/template/docs/uv-ui-docs/pick-color-cn.md +147 -0
  50. package/template/docs/uv-ui-docs/picker-cn.md +159 -0
  51. package/template/docs/uv-ui-docs/popup-cn.md +184 -0
  52. package/template/docs/uv-ui-docs/qrcode-cn.md +150 -0
  53. package/template/docs/uv-ui-docs/radio-cn.md +166 -0
  54. package/template/docs/uv-ui-docs/rate-cn.md +91 -0
  55. package/template/docs/uv-ui-docs/read-more-cn.md +191 -0
  56. package/template/docs/uv-ui-docs/scroll-list-cn.md +188 -0
  57. package/template/docs/uv-ui-docs/search-cn.md +107 -0
  58. package/template/docs/uv-ui-docs/skeleton-cn.md +101 -0
  59. package/template/docs/uv-ui-docs/skeletons-cn.md +312 -0
  60. package/template/docs/uv-ui-docs/slider-cn.md +98 -0
  61. package/template/docs/uv-ui-docs/steps-cn.md +158 -0
  62. package/template/docs/uv-ui-docs/sticky-cn.md +82 -0
  63. package/template/docs/uv-ui-docs/subsection-cn.md +161 -0
  64. package/template/docs/uv-ui-docs/swipe-action-cn.md +207 -0
  65. package/template/docs/uv-ui-docs/swiper-cn.md +247 -0
  66. package/template/docs/uv-ui-docs/switch-cn.md +136 -0
  67. package/template/docs/uv-ui-docs/tabbar-cn.md +224 -0
  68. package/template/docs/uv-ui-docs/tabs-cn.md +260 -0
  69. package/template/docs/uv-ui-docs/tags-cn.md +191 -0
  70. package/template/docs/uv-ui-docs/text-cn.md +178 -0
  71. package/template/docs/uv-ui-docs/textarea-cn.md +132 -0
  72. package/template/docs/uv-ui-docs/toast-cn.md +110 -0
  73. package/template/docs/uv-ui-docs/tooltip-cn.md +91 -0
  74. package/template/docs/uv-ui-docs/transition-cn.md +202 -0
  75. package/template/docs/uv-ui-docs/upload-cn.md +156 -0
  76. package/template/docs/uv-ui-docs/vtabs-cn.md +190 -0
  77. package/template/docs/uv-ui-docs/waterfall-cn.md +276 -0
  78. package/template/rules/common.mdc +90 -0
  79. package/template/rules/uv-ui-docs.mdc +111 -0
  80. package/template/skills/code-simplifier/SKILL.md +109 -0
  81. package/template/skills/frontend-design/SKILL.md +44 -0
@@ -0,0 +1,260 @@
1
+ ---
2
+ group: 导航
3
+ category: Components
4
+ title: Tabs
5
+ subtitle: 标签选项卡
6
+ description: 支持多标签滚动、粘性吸顶、徽标、禁用状态和丰富样式定制的选项卡组件。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-tabs` 用于在同一页面中 **多个内容区域切换展示** 的场景:
14
+
15
+ - 标签较多时可左右滑动
16
+ - 标签较少时可居中展示并禁止滚动
17
+ - 可与 `uv-sticky` 组合实现粘性吸顶
18
+ - 支持徽标、禁用状态、自定义样式和右侧插槽
19
+
20
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
21
+
22
+ ## 平台兼容性 {#platform}
23
+
24
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
25
+ | --- | --- | --- | --- | --- | --- |
26
+ | √ | √ | √ | √ | √ | √ |
27
+
28
+ **组件名:** `uv-tabs`
29
+
30
+ > 说明:
31
+ > 1. 内部使用 `scroll-view`,H5 等平台可能出现滚动条,建议全局引入基础样式去除滚动条;
32
+ > 2. 在弹窗等场景显示异常时,需使用 `v-if` 控制挂载时机。
33
+
34
+ ## 代码演示 {#examples}
35
+
36
+ ### 基本使用 {#basic}
37
+
38
+ 通过 `list` 配置标签数组,通过 `@click` 获取当前项信息。
39
+ 若需要更精细控制,结合 `current` + `@change` 使用。
40
+
41
+ ```vue
42
+ <template>
43
+ <uv-tabs :list="list" @click="click"></uv-tabs>
44
+ </template>
45
+
46
+ <script>
47
+ export default {
48
+ data() {
49
+ return {
50
+ list: [
51
+ { name: '关注' },
52
+ { name: '推荐' },
53
+ { name: '电影' },
54
+ { name: '科技' },
55
+ { name: '音乐' },
56
+ { name: '美食' },
57
+ { name: '文化' },
58
+ { name: '财经' },
59
+ { name: '手工' }
60
+ ]
61
+ }
62
+ },
63
+ methods: {
64
+ click(item) {
65
+ console.log('item', item)
66
+ }
67
+ }
68
+ }
69
+ </script>
70
+ ```
71
+
72
+ ### 粘性布局(配合 uv-sticky) {#sticky}
73
+
74
+ ```vue
75
+ <template>
76
+ <uv-sticky bgColor="#fff">
77
+ <uv-tabs :list="list"></uv-tabs>
78
+ </uv-sticky>
79
+ </template>
80
+ ```
81
+
82
+ ### 显示徽标 {#badge}
83
+
84
+ 通过 `list` 中的 `badge` 字段设置红点或数字。
85
+
86
+ ```vue
87
+ <template>
88
+ <uv-tabs :list="list"></uv-tabs>
89
+ </template>
90
+
91
+ <script>
92
+ export default {
93
+ data() {
94
+ return {
95
+ list: [
96
+ { name: '关注' },
97
+ {
98
+ name: '推荐',
99
+ badge: {
100
+ isDot: true
101
+ }
102
+ },
103
+ {
104
+ name: '电影',
105
+ badge: {
106
+ value: 5
107
+ }
108
+ },
109
+ { name: '科技' },
110
+ { name: '音乐' },
111
+ { name: '美食' },
112
+ { name: '文化' },
113
+ { name: '财经' },
114
+ { name: '手工' }
115
+ ]
116
+ }
117
+ }
118
+ }
119
+ </script>
120
+ ```
121
+
122
+ ### 禁用某些标签 {#disabled}
123
+
124
+ ```vue
125
+ <template>
126
+ <uv-tabs :list="list"></uv-tabs>
127
+ </template>
128
+
129
+ <script>
130
+ export default {
131
+ data() {
132
+ return {
133
+ list: [
134
+ { name: '关注', disabled: true },
135
+ {
136
+ name: '推荐',
137
+ badge: { isDot: true }
138
+ },
139
+ {
140
+ name: '电影',
141
+ badge: { value: 5 }
142
+ },
143
+ { name: '科技', disabled: true },
144
+ { name: '音乐' },
145
+ { name: '美食' },
146
+ { name: '文化' },
147
+ { name: '财经' },
148
+ { name: '手工' }
149
+ ]
150
+ }
151
+ }
152
+ }
153
+ </script>
154
+ ```
155
+
156
+ ### 自定义样式与滑块背景图 {#style}
157
+
158
+ 通过 `activeStyle` / `inactiveStyle` / `itemStyle` 控制文字和 item 样式;
159
+ 通过 `lineColor` 可设置滑块颜色或背景图。
160
+
161
+ ```vue
162
+ <template>
163
+ <uv-tabs
164
+ :list="list"
165
+ lineWidth="30"
166
+ lineColor="#f56c6c"
167
+ :activeStyle="{
168
+ color: '#303133',
169
+ fontWeight: 'bold',
170
+ transform: 'scale(1.05)'
171
+ }"
172
+ :inactiveStyle="{
173
+ color: '#606266',
174
+ transform: 'scale(1)'
175
+ }"
176
+ itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"
177
+ ></uv-tabs>
178
+ </template>
179
+ ```
180
+
181
+ 使用图片作为滑块背景:
182
+
183
+ ```vue
184
+ <template>
185
+ <uv-tabs :list="list" :lineColor="`url(${lineBg}) 100% 100%`"></uv-tabs>
186
+ </template>
187
+
188
+ <script>
189
+ const lineBg =
190
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAOCAYAAABdC15GAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFxSURBVHgBzZNRTsJAEIb/WTW+lpiY+FZPIDew3ABP4GJ8hxsI9zBpOYHeQDwBPQI+mRiRvpLojtPdYhCorQqF/6GdbGd2vvwzBXZcNAt4oj1ANeUoAT5iqkUjbEFLHNmhD1YPEvpZ3ghkGlVDCkc94/BmHMq998I5ONiY1ZBfpKAyuOtgAc5yOEDmYEWNh32BHF91sGHZHmwW4azciN9aQwnz3SJEgOmte+R2tdLprTYoa50mvuomlLpD4Y3oQZnov6D2RzCqI93bWOHaEmAGqQUyRBlZR1WfarcD/EJ2z8DtzDGvsMCwpm8XOCfDUsVOCYhiqRxI/CTQo4UOvjzO7Pow18vfywneuUHHUUxLn55lLw5JFpZ8bEUcY8oXdOLWiHLTxvoGpLqoUmy6dBT15o/ox3znpoycAmxUsiJTbs1cmxeVKp+0zmFIS7bGWiVghC7Vwse8jFKAX9eljh4ggKLLv7uaQvG9/F59Oo2SouxPu7OTCxN/s8wAAAAASUVORK5CYII='
191
+
192
+ export default {
193
+ data() {
194
+ return {
195
+ list: [{ name: '关注' }, { name: '推荐' }, { name: '电影' }],
196
+ lineBg
197
+ }
198
+ }
199
+ }
200
+ </script>
201
+ ```
202
+
203
+ ### 右侧自定义插槽 {#right-slot}
204
+
205
+ ```vue
206
+ <template>
207
+ <uv-tabs :list="list">
208
+ <template v-slot:right>
209
+ <view style="padding-left: 4px;" @tap="toast">
210
+ <uv-icon name="list" size="21" bold></uv-icon>
211
+ </view>
212
+ </template>
213
+ </uv-tabs>
214
+ </template>
215
+
216
+ <script>
217
+ export default {
218
+ data() {
219
+ return {
220
+ list: [{ name: '关注' }, { name: '推荐' }, { name: '电影' }]
221
+ }
222
+ },
223
+ methods: {
224
+ toast() {
225
+ uni.showToast({
226
+ icon: 'none',
227
+ title: '插槽被点击'
228
+ })
229
+ }
230
+ }
231
+ }
232
+ </script>
233
+ ```
234
+
235
+ ## API {#api}
236
+
237
+ ### Tabs Props {#props}
238
+
239
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
240
+ | --- | --- | --- | --- | --- |
241
+ | duration | 滑块移动一次所需时间(ms) | String \| Number | 300 | - |
242
+ | list | 标签数组,元素为对象,如 `{ name: '推荐' }` | Array | - | - |
243
+ | lineColor | 滑块颜色或背景(可为图片) | String | #3c9cff | - |
244
+ | activeStyle | 选中项样式 | String \| Object | `{ color: '#303133' }` | - |
245
+ | inactiveStyle | 未选中项样式 | String \| Object | `{ color: '#606266' }` | - |
246
+ | lineWidth | 滑块宽度 | String \| Number | 20 | - |
247
+ | lineHeight | 滑块高度 | String \| Number | 3 | - |
248
+ | lineBgSize | 滑块背景图显示大小 | String | cover | - |
249
+ | itemStyle | 每个菜单项样式 | String \| Object | `{ height: '44px' }` | - |
250
+ | scrollable | 菜单是否可滚动(选项少时建议设为 false 以居中) | Boolean | true | true \| false |
251
+ | current | 当前选中标签索引 | String \| Number | 0 | - |
252
+ | keyName | 从 `list` 对象中读取的键名 | String | name | - |
253
+ | customStyle | 自定义整体样式 | Object | - | - |
254
+
255
+ ### Tabs Events {#events}
256
+
257
+ | 事件名 | 说明 | 回调参数 |
258
+ | --- | --- | --- |
259
+ | @click | 点击标签时触发 | `index`: 索引,`item`: 对应对象 |
260
+ | @change | 标签索引改变时触发(`disabled` 不会触发) | `index`: 索引,`item`: 对应对象 |
@@ -0,0 +1,191 @@
1
+ ---
2
+ group: 数据
3
+ category: Components
4
+ title: Tags
5
+ subtitle: 标签
6
+ description: 用于标记与选择,支持主题色、尺寸、形状、镂空、可关闭与图标/图片等形态。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-tags` 常用于内容标记、筛选条件、状态展示等场景,提供更丰富的展示与交互形态(单选/多选可在点击事件中自行维护状态)。
14
+
15
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
16
+
17
+ ## 平台兼容性 {#platform}
18
+
19
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | √ | √ | √ | √ | √ | √ |
22
+
23
+ **组件名:** `uv-tags`
24
+
25
+ ## 代码演示 {#examples}
26
+
27
+ ### 基本使用 {#basic}
28
+
29
+ 通过 `type` 设置主题类型(默认 `primary`),通过 `text` 设置标签内容。
30
+
31
+ ```vue
32
+ <uv-tags text="标签" plain size="mini" type="warning"></uv-tags>
33
+ ```
34
+
35
+ ### 自定义主题 {#theme}
36
+
37
+ ```vue
38
+ <uv-tags text="标签"></uv-tags>
39
+ <uv-tags text="标签" type="warning"></uv-tags>
40
+ <uv-tags text="标签" type="success"></uv-tags>
41
+ <uv-tags text="标签" type="error"></uv-tags>
42
+ ```
43
+
44
+ ### 圆形标签 {#shape}
45
+
46
+ ```vue
47
+ <uv-tags text="标签" plain shape="circle"></uv-tags>
48
+ <uv-tags text="标签" type="warning" shape="circle"></uv-tags>
49
+ ```
50
+
51
+ ### 镂空与填充 {#plain}
52
+
53
+ ```vue
54
+ <uv-tags text="标签" plain></uv-tags>
55
+ <uv-tags text="标签" type="warning" plain></uv-tags>
56
+ <uv-tags text="标签" type="success" plain></uv-tags>
57
+ <uv-tags text="标签" type="error" plain></uv-tags>
58
+
59
+ <!-- plainFill:镂空但带背景色 -->
60
+ <uv-tags text="标签" type="warning" plain plainFill></uv-tags>
61
+ <uv-tags text="标签" type="success" plain plainFill></uv-tags>
62
+ <uv-tags text="标签" type="error" plain plainFill></uv-tags>
63
+ ```
64
+
65
+ ### 自定义尺寸 {#size}
66
+
67
+ `size` 可选 `mini / medium / large`(默认 `medium`)。
68
+
69
+ ```vue
70
+ <uv-tags text="标签" plain size="mini"></uv-tags>
71
+ <uv-tags text="标签" type="warning"></uv-tags>
72
+ <uv-tags text="标签" type="success" plain size="large"></uv-tags>
73
+ ```
74
+
75
+ ### 可关闭标签 {#closable}
76
+
77
+ ```vue
78
+ <template>
79
+ <view>
80
+ <uv-tags text="标签" size="mini" closable :show="close1" @close="close1 = false"></uv-tags>
81
+ <uv-tags text="标签" type="warning" closable :show="close2" @close="close2 = false"></uv-tags>
82
+ <uv-tags
83
+ text="标签"
84
+ type="success"
85
+ plain
86
+ size="large"
87
+ closable
88
+ :show="close3"
89
+ @close="close3 = false"
90
+ ></uv-tags>
91
+ </view>
92
+ </template>
93
+
94
+ <script>
95
+ export default {
96
+ data() {
97
+ return {
98
+ close1: true,
99
+ close2: true,
100
+ close3: true
101
+ }
102
+ }
103
+ }
104
+ </script>
105
+ ```
106
+
107
+ ### 带图片与图标 {#icon}
108
+
109
+ `icon` 可传内置图标名或绝对路径图片地址。
110
+
111
+ ```vue
112
+ <template>
113
+ <view>
114
+ <uv-tags text="标签" size="mini" icon="map" plain></uv-tags>
115
+ <uv-tags text="标签" type="warning" icon="tags-fill"></uv-tags>
116
+ <uv-tags
117
+ text="标签"
118
+ type="success"
119
+ plain
120
+ size="large"
121
+ icon="https://cdn.uviewui.com/uview/example/tag.png"
122
+ ></uv-tags>
123
+ </view>
124
+ </template>
125
+ ```
126
+
127
+ ### 单选与多选 {#select}
128
+
129
+ 通过 `@click` 事件拿到 `name`,自行维护选中态(示例仅展示多选)。
130
+
131
+ ```vue
132
+ <template>
133
+ <view>
134
+ <view class="uv-page__tag-item" v-for="(item, index) in checkboxs" :key="index">
135
+ <uv-tags :text="`选项${index + 1}`" :plain="!item.checked" type="warning" :name="index" @click="checkboxClick">
136
+ </uv-tags>
137
+ </view>
138
+ </view>
139
+ </template>
140
+
141
+ <script>
142
+ export default {
143
+ data() {
144
+ return {
145
+ checkboxs: [{ checked: true }, { checked: false }, { checked: false }]
146
+ }
147
+ },
148
+ methods: {
149
+ checkboxClick(name) {
150
+ this.checkboxs[name].checked = !this.checkboxs[name].checked
151
+ }
152
+ }
153
+ }
154
+ </script>
155
+
156
+ <style lang="scss">
157
+ .uv-page__tag-item {
158
+ margin-right: 20px;
159
+ }
160
+ </style>
161
+ ```
162
+
163
+ ## API {#api}
164
+
165
+ ### Tags Props {#props}
166
+
167
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
168
+ | --- | --- | --- | --- | --- |
169
+ | type | 主题类型 | String | primary | primary \| success \| info \| warning \| error |
170
+ | disabled | 不可用 | Boolean \| String | false | - |
171
+ | size | 标签大小 | String | medium | medium \| large \| mini |
172
+ | shape | 标签形状 | String | square | circle \| square |
173
+ | text | 标签文字内容 | String \| Number | - | - |
174
+ | bgColor | 背景颜色(为空则不处理) | String | #C6C7CB | - |
175
+ | color | 字体颜色(为空则不处理) | String | - | - |
176
+ | borderColor | 边框颜色 | String | - | - |
177
+ | closeColor | 关闭图标颜色 | String | - | - |
178
+ | name | 点击时返回的索引/标识 | String \| Number | - | - |
179
+ | plainFill | 镂空时是否填充背景色 | Boolean | false | true \| false |
180
+ | plain | 是否镂空 | Boolean | false | true \| false |
181
+ | closable | 是否可关闭 | Boolean | false | true \| false |
182
+ | show | 标签显示与否 | Boolean | true | true \| false |
183
+ | icon | 内置图标或绝对路径图片 | String | - | - |
184
+ | cellChild | 是否属于 cell 节点下(nvue 场景建议 true) | Boolean | false | true \| false |
185
+
186
+ ### Tags Events {#events}
187
+
188
+ | 事件名 | 说明 | 回调参数 |
189
+ | --- | --- | --- |
190
+ | @click | 点击标签触发 | index:传递的 name 值 |
191
+ | @close | closable 为 true 时,点击关闭按钮触发 | index:传递的 name 值 |
@@ -0,0 +1,178 @@
1
+ ---
2
+ group: 基础
3
+ category: Components
4
+ title: Text
5
+ subtitle: 文本
6
+ description: 集成常用文本能力(主题色、拨号、日期格式化、脱敏、超链接、金额等)。
7
+ cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*BD2JSKm8I-kAAAAAAAAAAAAADrJ8AQ/original
8
+ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*r29rQ51bNdwAAAAAAAAAAAAADrJ8AQ/original
9
+ demo:
10
+ cols: 2
11
+ ---
12
+
13
+ ## 何时使用 {#when-to-use}
14
+
15
+ `uv-text` 覆盖项目中「特殊文本」的大部分常见场景,如:
16
+
17
+ - 主题色(primary / error / success / warning / info)
18
+ - 拨打电话、手机号脱敏
19
+ - 日期格式化
20
+ - 姓名脱敏
21
+ - 超链接
22
+ - 金额展示
23
+ - 前后图标
24
+ - 多行省略
25
+ - 小程序 openType 能力(如分享)
26
+
27
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
28
+
29
+ ## 平台兼容性 {#platform}
30
+
31
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
32
+ | --- | --- | --- | --- | --- | --- |
33
+ | √ | √ | √ | √ | √ | √ |
34
+
35
+ **组件名:** `uv-text`
36
+
37
+ ## 代码演示 {#examples}
38
+
39
+ ### 基本使用 {#basic}
40
+
41
+ 通过 `text` 设置文本内容。推荐用 `:text="value"` 形式传入。
42
+
43
+ ```vue
44
+ <uv-text text="我用十年青春,赴你最后之约"></uv-text>
45
+ ```
46
+
47
+ ### 设置主题 {#type}
48
+
49
+ 通过 `type` 设置主题色:primary / error / success / warning / info。
50
+
51
+ ```vue
52
+ <uv-text type="primary" text="主色"></uv-text>
53
+ <uv-text type="error" text="错误"></uv-text>
54
+ <uv-text type="success" text="成功"></uv-text>
55
+ <uv-text type="warning" text="警告"></uv-text>
56
+ <uv-text type="info" text="信息"></uv-text>
57
+ ```
58
+
59
+ ### 拨打电话 + 脱敏 {#phone}
60
+
61
+ 设置 `mode="phone"`。可配合 `format="encrypt"` 进行脱敏。
62
+
63
+ ```vue
64
+ <uv-text mode="phone" text="15019479320"></uv-text>
65
+ <uv-text mode="phone" format="encrypt" text="15019479320"></uv-text>
66
+ ```
67
+
68
+ ### 日期格式化 {#date}
69
+
70
+ 设置 `mode="date"`。
71
+
72
+ ```vue
73
+ <uv-text mode="date" text="1612959739"></uv-text>
74
+ ```
75
+
76
+ ### 姓名脱敏 {#name}
77
+
78
+ 设置 `mode="name"` 并配合 `format="encrypt"`。
79
+
80
+ ```vue
81
+ <uv-text mode="name" text="张三三" format="encrypt"></uv-text>
82
+ ```
83
+
84
+ ### 超链接 {#link}
85
+
86
+ 设置 `mode="link"` 并指定 `href`。
87
+
88
+ ```vue
89
+ <uv-text mode="link" text="Go to uv-ui docs" href="https://www.uv-uiui.com"></uv-text>
90
+ ```
91
+
92
+ ### 显示金额 {#price}
93
+
94
+ 设置 `mode="price"`。
95
+
96
+ ```vue
97
+ <uv-text mode="price" text="728732.32"></uv-text>
98
+ ```
99
+
100
+ ### 前后图标 {#icons}
101
+
102
+ 设置 `prefixIcon` / `suffixIcon`,并用 `iconStyle` 调整图标样式(如字号)。图标名参考 `uv-icon`。
103
+
104
+ ```vue
105
+ <uv-text prefixIcon="baidu" iconStyle="font-size: 19px" text="百度一下,你就知道"></uv-text>
106
+ <uv-text suffixIcon="arrow-leftward" iconStyle="font-size: 18px" text="查看更多"></uv-text>
107
+ ```
108
+
109
+ ### 超出隐藏(多行省略) {#lines}
110
+
111
+ 通过 `lines` 指定最大显示行数(最大 5),超出显示省略号。
112
+
113
+ ```vue
114
+ <uv-text
115
+ :lines="2"
116
+ text="关于uv-ui的取名来由,首字母u来自于uni-app首字母,uni-app是基于Vue.js,Vue和View同音,故取名uv-ui,表达源于uni-app和Vue和uView之意,同时在此也对它们表示感谢。"
117
+ ></uv-text>
118
+ ```
119
+
120
+ ### 小程序开放能力(openType) {#open-type}
121
+
122
+ 小程序环境下可使用 `openType`(例如 `share`)。注意:使用 uni 上挂载的 uv-ui 内置方法,需要按「扩展配置 - JS 工具库」完成配置,否则可能报错。
123
+
124
+ ```vue
125
+ <template>
126
+ <uv-text text="分享到微信" openType="share" type="success" @click="clickHandler"></uv-text>
127
+ </template>
128
+ <script>
129
+ export default {
130
+ methods: {
131
+ clickHandler() {
132
+ // #ifndef MP-WEIXIN
133
+ uni.showToast({
134
+ icon: 'none',
135
+ title: '请在微信小程序内查看效果'
136
+ })
137
+ // #endif
138
+ }
139
+ }
140
+ }
141
+ </script>
142
+ ```
143
+
144
+ ## API {#api}
145
+
146
+ ### Text Props {#props}
147
+
148
+ | 参数 | 类型 | 默认值 | 说明 |
149
+ | --- | --- | --- | --- |
150
+ | text | String \| Number | - | 显示的值 |
151
+ | type | String | - | 主题颜色 |
152
+ | show | Boolean | true | 是否显示 |
153
+ | prefixIcon | String | - | 前置图标 |
154
+ | suffixIcon | String | - | 后置图标 |
155
+ | mode | String | - | 匹配模式:text(普通)/ price / phone / name / date / link |
156
+ | href | String | - | mode=link 时的链接 |
157
+ | format | String \| Function | - | 格式化规则 |
158
+ | call | Boolean | false | mode=phone 时点击是否拨打电话 |
159
+ | openType | String | - | 小程序开放能力 open-type |
160
+ | bold | Boolean | false | 是否粗体 |
161
+ | block | Boolean | false | 是否块状(仅 vue) |
162
+ | lines | String \| Number | - | 显示行数(最大 5),超出省略 |
163
+ | color | String | #303133 | 文本颜色 |
164
+ | size | String \| Number | 15 | 字体大小 |
165
+ | iconStyle | Object \| String | 15px | 图标样式 |
166
+ | decoration | String | none | 文字装饰:none \| underline \| line-through |
167
+ | margin | Object \| Number \| String | - | 外边距 |
168
+ | lineHeight | Number \| String | - | 行高 |
169
+ | align | String | left | 对齐:left \| center \| right |
170
+ | wordWrap | String | normal | 换行:normal \| break-word \| anywhere |
171
+ | customStyle | Object | - | 自定义样式,如 `:custom-style=\"{color:'red',width:'20px'}\"` |
172
+
173
+ ### Text Events {#events}
174
+
175
+ | 事件名 | 说明 | 回调参数 |
176
+ | --- | --- | --- |
177
+ | @click | 点击触发 | - |
178
+