|
2 | 2 |
|
3 | 3 | 悬浮动作按钮组件,按下可显示一组动作按钮。 |
4 | 4 |
|
5 | | - |
6 | | - |
7 | 5 | :::warning |
8 | 6 | 因为`uni-app`组件无法监听点击自己以外的地方,为了在点击页面其他地方时,可以自动关闭 `fab` ,建议使用组件库的 `useQueue` hook(会关闭所有 dropmenu、popover、toast、swipeAction、fab),在页面的根元素上监听点击事件的冒泡。 |
9 | 7 |
|
|
36 | 34 | import { useToast } from '@/uni_modules/wot-design-uni' |
37 | 35 | const { show: showToast } = useToast() |
38 | 36 | const type = ref<'primary' | 'success' | 'info' | 'warning' | 'error' | 'default'>('primary') |
39 | | -const position = ref<'left-top' |
40 | | - | 'right-top' |
41 | | - | 'left-bottom' |
42 | | - | 'right-bottom' |
43 | | - | 'left-center' |
44 | | - | 'right-center' |
45 | | - | 'top-center' |
46 | | - | 'bottom-center'>('left-bottom') |
| 37 | +const position = ref<'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | 'left-center' | 'right-center' | 'top-center' | 'bottom-center'>( |
| 38 | + 'left-bottom' |
| 39 | +) |
47 | 40 | const direction = ref<'top' | 'right' | 'bottom' | 'left'>('top') |
48 | 41 | const disabled = ref<boolean>(false) |
49 | 42 | ``` |
@@ -90,49 +83,56 @@ const active = ref<boolean>(false) |
90 | 83 |
|
91 | 84 | 通过`trigger`插槽自定义触发器,`expandable`控制点击触发器是否展开/收起动作按钮菜单。 |
92 | 85 |
|
93 | | - |
94 | 86 | ```html |
95 | 87 | <wd-fab position="left-bottom" :expandable="false"> |
96 | 88 | <template #trigger> |
97 | 89 | <wd-button @click="handleClick" icon="share" type="error">分享给朋友</wd-button> |
98 | 90 | </template> |
99 | 91 | </wd-fab> |
100 | 92 | ``` |
| 93 | + |
101 | 94 | ```ts |
102 | 95 | const handleClick = () => { |
103 | 96 | console.log('点击了') |
104 | 97 | } |
105 | | - |
106 | 98 | ``` |
107 | 99 |
|
108 | 100 | ## Attributes |
109 | 101 |
|
110 | | -| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | |
111 | | -| -------------- | ----------------------------------------------------- | ------------ |-------------------------------------------------------------------------------------------------------------------------------------------| ---------------------------------------------- | ---------------- | |
112 | | -| v-model:active | 是否激活 | boolean | - | false | 0.1.57 | |
113 | | -| type | 类型 | FabType | 'primary' | 'success' | 'info' | 'warning' | 'error' | 'default' | 'primary' | 0.1.57 | |
114 | | -| position | 悬浮按钮位置 | FabPosition | 'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | left-center | right-center | top-center | bottom-center | 'right-bottom' | 0.1.57 | |
115 | | -| draggable | 按钮能否拖动 | boolean | | false | 1.2.19 | |
116 | | -| direction | 悬浮按钮菜单弹出方向 | FabDirection | 'top' | 'right' | 'bottom' | 'left' | 'top' | 0.1.57 | |
117 | | -| disabled | 是否禁用 | boolean | - | false | 0.1.57 | |
118 | | -| inactiveIcon | 悬浮按钮未展开时的图标 | string | - | 'add' | 0.1.57 | |
119 | | -| activeIcon | 悬浮按钮展开时的图标 | string | - | 'close' | 0.1.57 | |
120 | | -| zIndex | 自定义悬浮按钮层级 | number | - | 99 | 0.1.57 | |
121 | | -| gap | 自定义悬浮按钮与可视区域边缘的间距 | FabGap | - | \{ top: 16, left: 16, right: 16, bottom: 16 \} | 1.2.26 | |
122 | | -| customStyle | 自定义样式 | string | - | '' | 0.1.57 | |
123 | | -| expandable | 用于控制点击时是否展开菜单,设置为 false 时触发 click | boolean | - | true | 1.3.11 | |
| 102 | +| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | |
| 103 | +| -------------- | ----------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- | -------- | |
| 104 | +| v-model:active | 是否激活 | boolean | - | false | 0.1.57 | |
| 105 | +| type | 类型 | FabType | 'primary' | 'success' | 'info' | 'warning' | 'error' | 'default' | 'primary' | 0.1.57 | |
| 106 | +| position | 悬浮按钮位置 | FabPosition | 'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | left-center | right-center | top-center | bottom-center | 'right-bottom' | 0.1.57 | |
| 107 | +| draggable | 按钮能否拖动 | boolean | | false | 1.2.19 | |
| 108 | +| direction | 悬浮按钮菜单弹出方向 | FabDirection | 'top' | 'right' | 'bottom' | 'left' | 'top' | 0.1.57 | |
| 109 | +| disabled | 是否禁用 | boolean | - | false | 0.1.57 | |
| 110 | +| inactiveIcon | 悬浮按钮未展开时的图标 | string | - | 'add' | 0.1.57 | |
| 111 | +| activeIcon | 悬浮按钮展开时的图标 | string | - | 'close' | 0.1.57 | |
| 112 | +| zIndex | 自定义悬浮按钮层级 | number | - | 99 | 0.1.57 | |
| 113 | +| gap | 自定义悬浮按钮与可视区域边缘的间距 | FabGap | - | \{ top: 16, left: 16, right: 16, bottom: 16 \} | 1.2.26 | |
| 114 | +| custom-style | 自定义样式 | string | - | '' | 0.1.57 | |
| 115 | +| expandable | 用于控制点击时是否展开菜单,设置为 false 时触发 click | boolean | - | true | 1.3.11 | |
124 | 116 |
|
125 | 117 | ## Events |
126 | 118 |
|
127 | | -| 事件名称 | 说明 | 参数 | 最低版本 | |
128 | | -| -------- | -------------------------------------------- | ---- | ---------------- | |
129 | | -| click | expandable 设置为 false 时,点击悬浮按钮触发 | — | 1.3.11 | |
| 119 | +| 事件名称 | 说明 | 参数 | 最低版本 | |
| 120 | +| -------- | -------------------------------------------- | ---- | -------- | |
| 121 | +| click | expandable 设置为 false 时,点击悬浮按钮触发 | — | 1.3.11 | |
| 122 | + |
| 123 | +## Methods |
| 124 | + |
| 125 | +| 方法名 | 说明 | 参数 | 最低版本 | |
| 126 | +| ------ | -------- | ---- | -------- | |
| 127 | +| open | 展开菜单 | - | 0.1.57 | |
| 128 | +| close | 收起菜单 | - | 0.1.57 | |
130 | 129 |
|
131 | 130 | ## Slot |
132 | 131 |
|
133 | | -| name | 说明 | 最低版本 | |
134 | | -| ------- | -------------------------------------------------------------- | ---------------- | |
135 | | -| trigger | 触发器插槽,用于自定义点击按钮,使用此插槽时组件不会抛出 click | 1.3.11 | |
| 132 | +| name | 说明 | 最低版本 | |
| 133 | +| ------- | -------------------------------------------------------------- | -------- | |
| 134 | +| default | 动作按钮,通常放置多个按钮 | 0.1.57 | |
| 135 | +| trigger | 触发器插槽,用于自定义点击按钮,使用此插槽时组件不会抛出 click | 1.3.11 | |
136 | 136 |
|
137 | 137 | ## 外部样式类 |
138 | 138 |
|
|
0 commit comments