@fox-js/phone-skills 4.0.1-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.
- package/README.md +30 -0
- package/foxui/SKILL.md +442 -0
- package/foxui/references/fox-action-sheet/doc.md +74 -0
- package/foxui/references/fox-actionsheet-item/doc.md +499 -0
- package/foxui/references/fox-animate/doc.md +66 -0
- package/foxui/references/fox-audio/doc.md +76 -0
- package/foxui/references/fox-avatar/doc.md +70 -0
- package/foxui/references/fox-back-top/doc.md +69 -0
- package/foxui/references/fox-badge/doc.md +72 -0
- package/foxui/references/fox-barrage/doc.md +116 -0
- package/foxui/references/fox-button/doc.md +203 -0
- package/foxui/references/fox-calendar/doc.md +346 -0
- package/foxui/references/fox-calendar-item/doc.md +331 -0
- package/foxui/references/fox-cascader/doc.md +78 -0
- package/foxui/references/fox-cascader-item/doc.md +710 -0
- package/foxui/references/fox-cell/doc.md +74 -0
- package/foxui/references/fox-checkbox-item/doc.md +387 -0
- package/foxui/references/fox-circle-progress/doc.md +65 -0
- package/foxui/references/fox-collapse/doc.md +71 -0
- package/foxui/references/fox-count-down/doc.md +78 -0
- package/foxui/references/fox-count-up/doc.md +178 -0
- package/foxui/references/fox-date-item/doc.md +437 -0
- package/foxui/references/fox-date-picker/doc.md +438 -0
- package/foxui/references/fox-dialog/doc.md +242 -0
- package/foxui/references/fox-divider/doc.md +149 -0
- package/foxui/references/fox-domain-provider/doc.md +93 -0
- package/foxui/references/fox-drag/doc.md +64 -0
- package/foxui/references/fox-dropdown/doc.md +138 -0
- package/foxui/references/fox-elevator/doc.md +66 -0
- package/foxui/references/fox-ellipsis/doc.md +69 -0
- package/foxui/references/fox-empty/doc.md +67 -0
- package/foxui/references/fox-fixed-nav/doc.md +72 -0
- package/foxui/references/fox-floating-button/doc.md +142 -0
- package/foxui/references/fox-grid/doc.md +69 -0
- package/foxui/references/fox-group/doc.md +295 -0
- package/foxui/references/fox-icon/doc.md +65 -0
- package/foxui/references/fox-image/doc.md +75 -0
- package/foxui/references/fox-image-preview/doc.md +79 -0
- package/foxui/references/fox-indicator/doc.md +70 -0
- package/foxui/references/fox-infinite-loading/doc.md +74 -0
- package/foxui/references/fox-input-item/doc.md +210 -0
- package/foxui/references/fox-input-number/doc.md +199 -0
- package/foxui/references/fox-input-number-item/doc.md +213 -0
- package/foxui/references/fox-item/doc.md +207 -0
- package/foxui/references/fox-layout/doc.md +273 -0
- package/foxui/references/fox-link-item/doc.md +158 -0
- package/foxui/references/fox-list/doc.md +71 -0
- package/foxui/references/fox-mapping/doc.md +251 -0
- package/foxui/references/fox-menu/doc.md +425 -0
- package/foxui/references/fox-message-box/doc.md +200 -0
- package/foxui/references/fox-money-item/doc.md +174 -0
- package/foxui/references/fox-more-button/doc.md +208 -0
- package/foxui/references/fox-navbar/doc.md +75 -0
- package/foxui/references/fox-notice-bar/doc.md +71 -0
- package/foxui/references/fox-notify/doc.md +72 -0
- package/foxui/references/fox-number-keyboard/doc.md +77 -0
- package/foxui/references/fox-over-lay/doc.md +70 -0
- package/foxui/references/fox-page/doc.md +76 -0
- package/foxui/references/fox-pagination/doc.md +73 -0
- package/foxui/references/fox-picker/doc.md +668 -0
- package/foxui/references/fox-picker-item/doc.md +389 -0
- package/foxui/references/fox-popover/doc.md +70 -0
- package/foxui/references/fox-popover-dialog/doc.md +113 -0
- package/foxui/references/fox-popup/doc.md +88 -0
- package/foxui/references/fox-price/doc.md +67 -0
- package/foxui/references/fox-progress/doc.md +74 -0
- package/foxui/references/fox-pull-refresh/doc.md +77 -0
- package/foxui/references/fox-radio-item/doc.md +384 -0
- package/foxui/references/fox-range/doc.md +65 -0
- package/foxui/references/fox-rate/doc.md +141 -0
- package/foxui/references/fox-rate-item/doc.md +137 -0
- package/foxui/references/fox-rolling-provider/doc.md +87 -0
- package/foxui/references/fox-search-bar/doc.md +91 -0
- package/foxui/references/fox-short-password/doc.md +78 -0
- package/foxui/references/fox-side-nav-bar/doc.md +68 -0
- package/foxui/references/fox-signature/doc.md +202 -0
- package/foxui/references/fox-skeleton/doc.md +73 -0
- package/foxui/references/fox-steps/doc.md +162 -0
- package/foxui/references/fox-steps-bar/doc.md +610 -0
- package/foxui/references/fox-sticky/doc.md +68 -0
- package/foxui/references/fox-swipe/doc.md +176 -0
- package/foxui/references/fox-swiper/doc.md +254 -0
- package/foxui/references/fox-switch/doc.md +162 -0
- package/foxui/references/fox-switch-item/doc.md +190 -0
- package/foxui/references/fox-tabbar/doc.md +63 -0
- package/foxui/references/fox-table/doc.md +640 -0
- package/foxui/references/fox-tabs/doc.md +67 -0
- package/foxui/references/fox-tabs-bar/doc.md +533 -0
- package/foxui/references/fox-tag/doc.md +213 -0
- package/foxui/references/fox-text/doc.md +84 -0
- package/foxui/references/fox-textarea-item/doc.md +106 -0
- package/foxui/references/fox-toast/doc.md +149 -0
- package/foxui/references/fox-tour/doc.md +89 -0
- package/foxui/references/fox-trend-arrow/doc.md +72 -0
- package/foxui/references/fox-uploader/doc.md +96 -0
- package/foxui/references/fox-video/doc.md +245 -0
- package/foxui/references/fox-water-mark/doc.md +81 -0
- package/package.json +21 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: Swipe 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 列表项左滑删除场景使用
|
|
12
|
+
tags: [foxui, fox-swipe, FoxSwipe]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js","fox-cell","fox-button","fox-switch","fox-input-number"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Swipe 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
Swipe 是 foxui 中用于 **列表项左滑删除场景使用** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-swipe` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、支持 v-model 双向绑定、支持禁用/只读状态、适配 H5 与小程序多端、支持插槽扩展自定义内容
|
|
24
|
+
- **适用场景**: 列表项左滑删除场景使用
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 列表项左滑删除场景使用 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `name` | 唯一标识 | String | - |
|
|
37
|
+
| `disabled` | 是否禁用滑动 | String | false |
|
|
38
|
+
| `touch-move-prevent-default` | 是否阻止滑动事件行为 | boolean | false |
|
|
39
|
+
| `touch-move-stop-propagation` | 是否阻止滑动事件冒泡 | boolean | false |
|
|
40
|
+
|
|
41
|
+
### 2.2 Events 事件
|
|
42
|
+
|
|
43
|
+
| 事件名 | 类型 | 说明 |
|
|
44
|
+
| :--- | :--- | :--- |
|
|
45
|
+
| `open` | 打开时触发 | type:'left or right' |
|
|
46
|
+
| `close` | 关闭时触发 | type:'left or right' |
|
|
47
|
+
|
|
48
|
+
### 2.3 Methods 方法
|
|
49
|
+
|
|
50
|
+
| 方法名 | 参数 | 说明 |
|
|
51
|
+
| :--- | :--- | :--- |
|
|
52
|
+
| `open` | 打开单元格侧边栏 | left or right |
|
|
53
|
+
| `close` | 收起单元格侧边栏 |
|
|
54
|
+
|
|
55
|
+
### 2.4 Slots 插槽
|
|
56
|
+
|
|
57
|
+
| 插槽名 | 说明 |
|
|
58
|
+
| :--- | :--- |
|
|
59
|
+
| `left` | 左侧滑动内容 |
|
|
60
|
+
| `default` | 自定义内容 |
|
|
61
|
+
| `right` | 右侧滑动内容 |
|
|
62
|
+
|
|
63
|
+
## 3. 例子 (Examples)
|
|
64
|
+
|
|
65
|
+
## 代码演示
|
|
66
|
+
|
|
67
|
+
### 基础用法
|
|
68
|
+
|
|
69
|
+
``` html
|
|
70
|
+
<fox-swipe>
|
|
71
|
+
<fox-cell round-radius="0" desc="左滑删除" />
|
|
72
|
+
<template #right>
|
|
73
|
+
<fox-button shape="square" style="height:100%" type="danger">删除</fox-button>
|
|
74
|
+
</template>
|
|
75
|
+
</fox-swipe>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### 禁止滑动
|
|
80
|
+
|
|
81
|
+
``` html
|
|
82
|
+
<fox-swipe disabled>
|
|
83
|
+
<fox-cell round-radius="0" desc="禁止滑动" />
|
|
84
|
+
<template #right>
|
|
85
|
+
<fox-button shape="square" style="height:100%" type="danger">删除</fox-button>
|
|
86
|
+
</template>
|
|
87
|
+
</fox-swipe>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### 左右滑动
|
|
92
|
+
|
|
93
|
+
``` html
|
|
94
|
+
<fox-swipe>
|
|
95
|
+
<template #left>
|
|
96
|
+
<fox-button shape="square" style="height:100%" type="success">选择</fox-button>
|
|
97
|
+
</template>
|
|
98
|
+
<fox-cell round-radius="0" desc="左滑右滑都可以哦" />
|
|
99
|
+
<template #right>
|
|
100
|
+
<fox-button shape="square" style="height:100%" type="danger">删除</fox-button>
|
|
101
|
+
<fox-button shape="square" style="height:100%" type="info">收藏</fox-button>
|
|
102
|
+
</template>
|
|
103
|
+
</fox-swipe>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### 异步控制
|
|
108
|
+
|
|
109
|
+
``` html
|
|
110
|
+
<fox-swipe ref="refSwipe" @open="open" @close="close">
|
|
111
|
+
<fox-cell title="异步打开关闭">
|
|
112
|
+
<template v-slot:link>
|
|
113
|
+
<fox-switch v-model="checked" @change="changSwitch" active-text="开" inactive-text="关" />
|
|
114
|
+
</template>
|
|
115
|
+
</fox-cell>
|
|
116
|
+
<template #right>
|
|
117
|
+
<fox-button shape="square" style="height:100%" type="danger">删除</fox-button>
|
|
118
|
+
</template>
|
|
119
|
+
</fox-swipe>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
``` typescript
|
|
123
|
+
setup() {
|
|
124
|
+
const refSwipe = ref<HTMLElement>();
|
|
125
|
+
const checked = ref(false);
|
|
126
|
+
const changSwitch = (value: boolean) => {
|
|
127
|
+
if (value) {
|
|
128
|
+
refSwipe.value?.open('left');
|
|
129
|
+
} else {
|
|
130
|
+
refSwipe.value?.close();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const open = (obj: any) => {
|
|
134
|
+
console.log(obj);
|
|
135
|
+
checked.value = true;
|
|
136
|
+
};
|
|
137
|
+
const close = () => {
|
|
138
|
+
checked.value = false;
|
|
139
|
+
};
|
|
140
|
+
return { checked, changSwitch, refSwipe, open, close };
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 自定义
|
|
145
|
+
|
|
146
|
+
``` html
|
|
147
|
+
<fox-swipe>
|
|
148
|
+
<template #left>
|
|
149
|
+
<fox-button shape="square" style="height:100%" type="success">选择</fox-button>
|
|
150
|
+
</template>
|
|
151
|
+
<fox-cell title="商品描述">
|
|
152
|
+
<template v-slot:link>
|
|
153
|
+
<fox-input-number v-model="number" />
|
|
154
|
+
</template>
|
|
155
|
+
</fox-cell>
|
|
156
|
+
<template #right>
|
|
157
|
+
<fox-button shape="square" style="height:100%" type="danger">删除</fox-button>
|
|
158
|
+
<fox-button shape="square" style="height:100%" type="info">收藏</fox-button>
|
|
159
|
+
</template>
|
|
160
|
+
</fox-swipe>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
``` typescript
|
|
164
|
+
setup() {
|
|
165
|
+
const number = ref(0);
|
|
166
|
+
return { number };
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 4. 相关组件 (Related Components)
|
|
171
|
+
- **fox-js**: 与 Swipe 配合使用的相关组件
|
|
172
|
+
- **fox-cell**: 与 Swipe 配合使用的相关组件
|
|
173
|
+
- **fox-button**: 与 Swipe 配合使用的相关组件
|
|
174
|
+
- **fox-switch**: 与 Swipe 配合使用的相关组件
|
|
175
|
+
- **fox-input-number**: 与 Swipe 配合使用的相关组件
|
|
176
|
+
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: Swiper 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 轮播
|
|
12
|
+
tags: [foxui, fox-swiper, FoxSwiper]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js","fox-swiper-item"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Swiper 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
Swiper 是 foxui 中用于 **轮播** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-swiper` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、支持插槽扩展自定义内容、支持主题定制
|
|
24
|
+
- **适用场景**: 轮播
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 轮播 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `width` | 轮播卡片的宽度 | number \ | string |
|
|
37
|
+
| `height` | 轮播卡片的高度 | number \ | string |
|
|
38
|
+
| `direction` | 轮播方向,可选值horizontal,vertical | string | 'horizontal' |
|
|
39
|
+
| `pagination-visible` | 分页指示器是否展示 | boolean | false |
|
|
40
|
+
| `pagination-color` | 分页指示器选中的颜色 | string | 'fff' |
|
|
41
|
+
| `loop` | 是否循环轮播 | boolean | true |
|
|
42
|
+
| `duration` | 动画时长(单位是ms) | number \ | string |
|
|
43
|
+
| `auto-play` | 自动轮播时长,0表示不会自动轮播 | number \ | string |
|
|
44
|
+
| `init-page` | 初始化索引值 | number \ | string |
|
|
45
|
+
| `touchable` | 是否可触摸滑动 | boolean | true |
|
|
46
|
+
| `is-prevent-default` | 滑动过程中是否禁用默认事件 | boolean | true |
|
|
47
|
+
| `is-stop-propagation` | 滑动过程中是否禁止冒泡 | boolean | true |
|
|
48
|
+
|
|
49
|
+
### 2.2 Events 事件
|
|
50
|
+
|
|
51
|
+
| 事件名 | 类型 | 说明 |
|
|
52
|
+
| :--- | :--- | :--- |
|
|
53
|
+
| `change` | 滑动之后的回调 | 当前索引值 index |
|
|
54
|
+
|
|
55
|
+
### 2.3 Methods 方法
|
|
56
|
+
|
|
57
|
+
| 方法名 | 参数 | 说明 |
|
|
58
|
+
| :--- | :--- | :--- |
|
|
59
|
+
| `prev` | 切换到上一页 | - |
|
|
60
|
+
| `next` | 切换到下一页 | - |
|
|
61
|
+
| `to` | 切换到指定轮播 | index:number |
|
|
62
|
+
|
|
63
|
+
### 2.4 Slots 插槽
|
|
64
|
+
|
|
65
|
+
| 插槽名 | 说明 |
|
|
66
|
+
| :--- | :--- |
|
|
67
|
+
| `page` | 自定义指示器 |
|
|
68
|
+
|
|
69
|
+
## 3. 例子 (Examples)
|
|
70
|
+
|
|
71
|
+
## 代码演示
|
|
72
|
+
|
|
73
|
+
### 基础用法
|
|
74
|
+
|
|
75
|
+
`auto-play` 自动轮播的时长
|
|
76
|
+
`init-page` 初始索引值
|
|
77
|
+
`pagination-visible` 是否显示分页指示器
|
|
78
|
+
`pagination-color` 指示器颜色自定义
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<fox-swiper :init-page="state.page" :pagination-visible="true" pagination-color="#426543" auto-play="3000">
|
|
82
|
+
<fox-swiper-item>
|
|
83
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
84
|
+
</fox-swiper-item>
|
|
85
|
+
<fox-swiper-item>
|
|
86
|
+
<img src="./demo/img/2.jpg'" alt="" />
|
|
87
|
+
</fox-swiper-item>
|
|
88
|
+
<fox-swiper-item>
|
|
89
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
90
|
+
</fox-swiper-item>
|
|
91
|
+
<fox-swiper-item>
|
|
92
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
93
|
+
</fox-swiper-item>
|
|
94
|
+
</fox-swiper>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 自定义大小
|
|
98
|
+
|
|
99
|
+
`width` 自定义轮播大小
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<fox-swiper :init-page="state.page2" :loop="false" width="300">
|
|
103
|
+
<fox-swiper-item>
|
|
104
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
105
|
+
</fox-swiper-item>
|
|
106
|
+
<fox-swiper-item>
|
|
107
|
+
<img src="./demo/img/2.jpg'" alt="" />
|
|
108
|
+
</fox-swiper-item>
|
|
109
|
+
<fox-swiper-item>
|
|
110
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
111
|
+
</fox-swiper-item>
|
|
112
|
+
<fox-swiper-item>
|
|
113
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
114
|
+
</fox-swiper-item>
|
|
115
|
+
</fox-swiper>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 自定义分页指示器
|
|
119
|
+
|
|
120
|
+
`v-slot:page` 表示自定义指示器
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<fox-swiper :init-page="state.page3" :loop="true" @change="change">
|
|
124
|
+
<fox-swiper-item>
|
|
125
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
126
|
+
</fox-swiper-item>
|
|
127
|
+
<fox-swiper-item>
|
|
128
|
+
<img src="./demo/img/2.jpg'" alt="" />
|
|
129
|
+
</fox-swiper-item>
|
|
130
|
+
<fox-swiper-item>
|
|
131
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
132
|
+
</fox-swiper-item>
|
|
133
|
+
<fox-swiper-item>
|
|
134
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
135
|
+
</fox-swiper-item>
|
|
136
|
+
<template v-slot:page>
|
|
137
|
+
<div class="page"></div>
|
|
138
|
+
</template>
|
|
139
|
+
</fox-swiper>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 垂直方向
|
|
143
|
+
|
|
144
|
+
`direction` 自定义轮播方向
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<fox-swiper :init-page="state.page4" :loop="true" auto-play="3000" direction="vertical" height="150" :pagination-visible="true" style="height: 150px">
|
|
149
|
+
<fox-swiper-item>
|
|
150
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
151
|
+
</fox-swiper-item>
|
|
152
|
+
<fox-swiper-item>
|
|
153
|
+
<img src="./demo/img/2.jpg'" alt="" />
|
|
154
|
+
</fox-swiper-item>
|
|
155
|
+
<fox-swiper-item>
|
|
156
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
157
|
+
</fox-swiper-item>
|
|
158
|
+
<fox-swiper-item>
|
|
159
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
160
|
+
</fox-swiper-item>
|
|
161
|
+
</fox-swiper>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 水平居中展示
|
|
165
|
+
|
|
166
|
+
`is-center` 代表可居中,同时必须传 `width`
|
|
167
|
+
|
|
168
|
+
```html
|
|
169
|
+
<template>
|
|
170
|
+
<fox-swiper :init-page="page" :loop="false" width="280" height="150" :is-center="true" style="height: 150px">
|
|
171
|
+
<fox-swiper-item>
|
|
172
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
173
|
+
</fox-swiper-item>
|
|
174
|
+
<fox-swiper-item>
|
|
175
|
+
<img src="./demo/img/2.jpg'" alt="" />
|
|
176
|
+
</fox-swiper-item>
|
|
177
|
+
<fox-swiper-item>
|
|
178
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
179
|
+
</fox-swiper-item>
|
|
180
|
+
<fox-swiper-item>
|
|
181
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
182
|
+
</fox-swiper-item>
|
|
183
|
+
</fox-swiper>
|
|
184
|
+
</template>
|
|
185
|
+
<script lang="ts">
|
|
186
|
+
import { reactive, toRefs } from 'vue';
|
|
187
|
+
export default {
|
|
188
|
+
setup() {
|
|
189
|
+
const state = reactive({
|
|
190
|
+
page: 0
|
|
191
|
+
});
|
|
192
|
+
return { ...toRefs(state) };
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
</script>
|
|
196
|
+
<style lang="scss" scoped>
|
|
197
|
+
.fox-swiper-item {
|
|
198
|
+
line-height: 150px;
|
|
199
|
+
img {
|
|
200
|
+
width: 100%;
|
|
201
|
+
height: 100%;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
</style>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
### 垂直居中展示
|
|
209
|
+
|
|
210
|
+
`is-center` 代表可居中,同时必须传 `height`
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<template>
|
|
214
|
+
<fox-swiper :init-page="page" :loop="false" direction="vertical" height="220" :is-center="true" style="height: 300px">
|
|
215
|
+
<fox-swiper-item>
|
|
216
|
+
<img src="./demo/img/1.jpg" alt="" />
|
|
217
|
+
</fox-swiper-item>
|
|
218
|
+
<fox-swiper-item>
|
|
219
|
+
<img src="./demo/img/2.jpg" alt="" />
|
|
220
|
+
</fox-swiper-item>
|
|
221
|
+
<fox-swiper-item>
|
|
222
|
+
<img src="./demo/img/3.jpg" alt="" />
|
|
223
|
+
</fox-swiper-item>
|
|
224
|
+
<fox-swiper-item>
|
|
225
|
+
<img src="./demo/img/4.jpg" alt="" />
|
|
226
|
+
</fox-swiper-item>
|
|
227
|
+
</fox-swiper>
|
|
228
|
+
</template>
|
|
229
|
+
<script lang="ts">
|
|
230
|
+
import { reactive, toRefs } from 'vue';
|
|
231
|
+
export default {
|
|
232
|
+
setup() {
|
|
233
|
+
const state = reactive({
|
|
234
|
+
page: 0
|
|
235
|
+
});
|
|
236
|
+
return { ...toRefs(state) };
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
</script>
|
|
240
|
+
<style lang="scss" scoped>
|
|
241
|
+
.fox-swiper-item {
|
|
242
|
+
line-height: 300px;
|
|
243
|
+
img {
|
|
244
|
+
width: 100%;
|
|
245
|
+
height: 100%;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
</style>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## 4. 相关组件 (Related Components)
|
|
252
|
+
- **fox-js**: 与 Swiper 配合使用的相关组件
|
|
253
|
+
- **fox-swiper-item**: 与 Swiper 配合使用的相关组件
|
|
254
|
+
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: Switch 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 用来打开或关闭选项
|
|
12
|
+
tags: [foxui, fox-switch, FoxSwitch]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Switch 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
Switch 是 foxui 中用于 **用来打开或关闭选项** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-switch` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、支持 v-model 双向绑定、适配 H5 与小程序多端、支持主题定制
|
|
24
|
+
- **适用场景**: 用来打开或关闭选项
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 用来打开或关闭选项 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `v-model` | 开关状态 | Boolean、String、Number | false |
|
|
37
|
+
| `disable` | 禁用状态 | Boolean | false |
|
|
38
|
+
| `loading` | 加载状态 | Boolean | false |
|
|
39
|
+
| `name` | 图标名称/icon | String | loading |
|
|
40
|
+
| `color` | 图标颜色/icon,仅在loading状态下生效 | String | - |
|
|
41
|
+
| `size` | 图标尺寸/icon,仅在loading状态下生效 | String、Number | 12px |
|
|
42
|
+
| `active-color` | 打开时的背景颜色 | String | fa2c19 |
|
|
43
|
+
| `inactive-color` | 关闭时的背景颜色 | String | ebebeb |
|
|
44
|
+
| `active-text` | 打开时文字描述 | String | - |
|
|
45
|
+
| `inactive-text` | 关闭时文字描述 | String | - |
|
|
46
|
+
| `active-value` | 打开时组件的值 | Boolean、String、Number | true |
|
|
47
|
+
| `inactive-value` | 关闭组件的值 | Boolean、String、Number | false |
|
|
48
|
+
|
|
49
|
+
### 2.2 Events 事件
|
|
50
|
+
|
|
51
|
+
| 事件名 | 类型 | 说明 |
|
|
52
|
+
| :--- | :--- | :--- |
|
|
53
|
+
| `change` | 切换开关时触发 | value: boolean,event: Event |
|
|
54
|
+
|
|
55
|
+
### 2.3 Methods 方法
|
|
56
|
+
|
|
57
|
+
| 方法名 | 参数 | 说明 |
|
|
58
|
+
| :--- | :--- | :--- |
|
|
59
|
+
无
|
|
60
|
+
|
|
61
|
+
### 2.4 Slots 插槽
|
|
62
|
+
|
|
63
|
+
| 插槽名 | 说明 |
|
|
64
|
+
| :--- | :--- |
|
|
65
|
+
无
|
|
66
|
+
|
|
67
|
+
## 3. 例子 (Examples)
|
|
68
|
+
|
|
69
|
+
## 代码演示
|
|
70
|
+
|
|
71
|
+
### 基础用法
|
|
72
|
+
|
|
73
|
+
``` html
|
|
74
|
+
<fox-switch v-model="checked" />
|
|
75
|
+
```
|
|
76
|
+
``` javascript
|
|
77
|
+
import { ref } from 'vue';
|
|
78
|
+
export default {
|
|
79
|
+
setup() {
|
|
80
|
+
const checked = ref(true);
|
|
81
|
+
return { checked };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 禁用状态
|
|
87
|
+
|
|
88
|
+
``` html
|
|
89
|
+
<fox-switch v-model="checked" disable />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 加载状态
|
|
93
|
+
|
|
94
|
+
``` html
|
|
95
|
+
<fox-switch v-model="checked" loading color="loading" />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### change事件
|
|
99
|
+
|
|
100
|
+
``` html
|
|
101
|
+
<fox-switch v-model="checked" @change="change" />
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
``` javascript
|
|
105
|
+
import { ref, getCurrentInstance } from 'vue';
|
|
106
|
+
export default {
|
|
107
|
+
setup() {
|
|
108
|
+
let { proxy } = getCurrentInstance() as any;
|
|
109
|
+
const checked = ref(true);
|
|
110
|
+
const change = (value: boolean, event: Event) => {
|
|
111
|
+
proxy.$toast.text(`触发了change事件,开关状态:${value}`);
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
checked,
|
|
115
|
+
change
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 异步控制
|
|
122
|
+
|
|
123
|
+
``` html
|
|
124
|
+
<fox-switch :model-value="checkedAsync" @change="changeAsync" />
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
``` javascript
|
|
128
|
+
import { ref, getCurrentInstance } from 'vue';
|
|
129
|
+
export default {
|
|
130
|
+
setup() {
|
|
131
|
+
let { proxy } = getCurrentInstance() as any;
|
|
132
|
+
const checkedAsync = ref(true);
|
|
133
|
+
const changeAsync = (value: boolean, event: Event) => {
|
|
134
|
+
proxy.$toast.text(`2秒后异步触发 ${value}`);
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
checkedAsync.value = value;
|
|
137
|
+
}, 2000);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
checkedAsync,
|
|
142
|
+
changeAsync
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 自定义颜色
|
|
149
|
+
|
|
150
|
+
``` html
|
|
151
|
+
<fox-switch v-model="checked" @change="switchChange" active-color="blue" />
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 支持文字
|
|
155
|
+
|
|
156
|
+
``` html
|
|
157
|
+
<fox-switch v-model="checked" @change="switchChange" active-text="开" inactive-text="关" />
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 4. 相关组件 (Related Components)
|
|
161
|
+
- **fox-js**: 与 Switch 配合使用的相关组件
|
|
162
|
+
|