📝: 补充 dropdown 文档
This commit is contained in:
parent
e825f6d3e1
commit
e20b1cb6b0
@ -302,10 +302,16 @@ const handleClick = () => {
|
|||||||
if (props.disabled || (openState.value && !props.clickToClose)) {
|
if (props.disabled || (openState.value && !props.clickToClose)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (triggerMethods.value.includes("click")) {
|
||||||
triggerMethods.value.includes("click") ||
|
toggle();
|
||||||
triggerMethods.value.includes("contextMenu")
|
}
|
||||||
) {
|
};
|
||||||
|
|
||||||
|
const handleContextMenuClick = () => {
|
||||||
|
if (props.disabled || (openState.value && !props.clickToClose)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (triggerMethods.value.includes("contextMenu")) {
|
||||||
toggle();
|
toggle();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -397,7 +403,7 @@ watch(
|
|||||||
|
|
||||||
provide("openState", openState);
|
provide("openState", openState);
|
||||||
|
|
||||||
defineExpose({ open, hide, toggle });
|
defineExpose({open, hide, toggle});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -410,7 +416,9 @@ defineExpose({ open, hide, toggle });
|
|||||||
@focusout="handleFocusout()"
|
@focusout="handleFocusout()"
|
||||||
:class="{ 'layui-dropdown-up': openState }"
|
:class="{ 'layui-dropdown-up': openState }"
|
||||||
>
|
>
|
||||||
<div @click="handleClick()" @contextmenu.prevent="handleClick()">
|
<div
|
||||||
|
@click="handleClick()"
|
||||||
|
@contextmenu.prevent="handleContextMenuClick()">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
<dl
|
<dl
|
||||||
|
@ -76,6 +76,96 @@ export default {
|
|||||||
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
||||||
</lay-dropdown-menu>
|
</lay-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
|
</lay-dropdown>
|
||||||
|
|
||||||
|
<lay-dropdown trigger="focus">
|
||||||
|
<lay-input placeholder="Focus 触发"></lay-input>
|
||||||
|
<template #content>
|
||||||
|
<lay-dropdown-menu>
|
||||||
|
<lay-dropdown-menu-item>选项一</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项二</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
||||||
|
</lay-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</lay-dropdown>
|
||||||
|
|
||||||
|
<lay-dropdown :trigger="['hover','focus','click']">
|
||||||
|
<lay-input placeholder="hover focus click"></lay-input>
|
||||||
|
<template #content>
|
||||||
|
<lay-dropdown-menu>
|
||||||
|
<lay-dropdown-menu-item>选项一</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项二</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
||||||
|
</lay-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</lay-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: title 手动打开或关闭
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: demo
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<lay-button @click="manualRef.open()">打开</lay-button>
|
||||||
|
<lay-button @click="manualRef.hide()">关闭</lay-button>
|
||||||
|
<br><br>
|
||||||
|
<lay-dropdown ref="manualRef" :clickOutsideToClose="false" :clickToClose="false">
|
||||||
|
<lay-button type="primary">下拉菜单</lay-button>
|
||||||
|
<template #content>
|
||||||
|
<lay-dropdown-menu>
|
||||||
|
<lay-dropdown-menu-item>选项一</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项二</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
||||||
|
</lay-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</lay-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const manualRef = ref()
|
||||||
|
|
||||||
|
return {
|
||||||
|
manualRef,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: title 默认打开
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: demo
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<lay-dropdown :visible="true" updateAtScroll>
|
||||||
|
<lay-button type="primary">下拉菜单</lay-button>
|
||||||
|
<template #content>
|
||||||
|
<lay-dropdown-menu>
|
||||||
|
<lay-dropdown-menu-item>选项一</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项二</lay-dropdown-menu-item>
|
||||||
|
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
||||||
|
</lay-dropdown-menu>
|
||||||
|
</template>
|
||||||
</lay-dropdown>
|
</lay-dropdown>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -91,8 +181,9 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
::: title 禁用弹出
|
::: title 禁用弹出
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -158,7 +249,7 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
::: title 位置优化
|
::: title 弹出位置
|
||||||
:::
|
:::
|
||||||
|
|
||||||
::: demo
|
::: demo
|
||||||
@ -205,8 +296,35 @@ export default {
|
|||||||
<div style="width:300px;height:200px;"></div>
|
<div style="width:300px;height:200px;"></div>
|
||||||
</template>
|
</template>
|
||||||
</lay-dropdown>
|
</lay-dropdown>
|
||||||
|
</template>
|
||||||
<br><br>
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
|
||||||
|
const btnSize = ref('')
|
||||||
|
const toogleSize = () => {
|
||||||
|
btnSize.value = btnSize.value ? '' : 'lg'
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
btnSize,
|
||||||
|
toogleSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: title 其它属性
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: demo
|
||||||
|
|
||||||
|
<template>
|
||||||
<lay-dropdown placement="bottom-left" autoFitWidth>
|
<lay-dropdown placement="bottom-left" autoFitWidth>
|
||||||
<lay-button type="primary">autoFitWidth</lay-button>
|
<lay-button type="primary">autoFitWidth</lay-button>
|
||||||
<template #content>
|
<template #content>
|
||||||
@ -251,22 +369,20 @@ export default {
|
|||||||
</template>
|
</template>
|
||||||
</lay-dropdown>
|
</lay-dropdown>
|
||||||
|
|
||||||
<lay-dropdown placement="bottom-left" :autoFixPosition="true" :clickOutsideToClose="false">
|
<br><br>
|
||||||
<lay-button type="primary" :size="btnSize">autoFixPosition</lay-button>
|
<lay-button @click="triggerHeight += 100">改变触发器尺寸</lay-button>
|
||||||
|
<lay-button @click="contentHeight += 100">改变面板尺寸</lay-button>
|
||||||
|
<br><br>
|
||||||
|
<lay-dropdown placement="bottom-left" trigger="focus" :autoFitPosition="true" :autoFixPosition="true" :blurToClose="false" :clickOutsideToClose="false">
|
||||||
|
<lay-input placeholder="autoFixPosition" :style="{height: triggerHeight + 'px'}"></lay-input>
|
||||||
<template #content>
|
<template #content>
|
||||||
<lay-dropdown-menu>
|
<div :style="{width:'350px', height: contentHeight + 'px'}"></div>
|
||||||
<lay-dropdown-menu-item>选项一</lay-dropdown-menu-item>
|
|
||||||
<lay-dropdown-menu-item>选项二111111111</lay-dropdown-menu-item>
|
|
||||||
<lay-dropdown-menu-item>选项三</lay-dropdown-menu-item>
|
|
||||||
</lay-dropdown-menu>
|
|
||||||
</template>
|
</template>
|
||||||
</lay-dropdown>
|
</lay-dropdown>
|
||||||
|
|
||||||
<lay-button @click="toogleSize">切换左边按钮</lay-button>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
@ -276,9 +392,14 @@ export default {
|
|||||||
btnSize.value = btnSize.value ? '' : 'lg'
|
btnSize.value = btnSize.value ? '' : 'lg'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const triggerHeight = ref(100)
|
||||||
|
const contentHeight = ref(200)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
btnSize,
|
btnSize,
|
||||||
toogleSize
|
toogleSize,
|
||||||
|
triggerWidth,
|
||||||
|
triggerStyle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,9 +422,9 @@ export default {
|
|||||||
| autoFitWidth | 是否将下拉面板宽度设置为触发器宽度, 默认 `false` |`true` `false` |
|
| autoFitWidth | 是否将下拉面板宽度设置为触发器宽度, 默认 `false` |`true` `false` |
|
||||||
| autoFitMinWidth | 是否将下拉面板最小宽度设置为触发器宽度, 默认 `true` |`true` `false` |
|
| autoFitMinWidth | 是否将下拉面板最小宽度设置为触发器宽度, 默认 `true` |`true` `false` |
|
||||||
| updateAtScroll | 是否在容器滚动时更新下拉面板的位置,默认 `false` | `true` `false` |
|
| updateAtScroll | 是否在容器滚动时更新下拉面板的位置,默认 `false` | `true` `false` |
|
||||||
| autoFixPosition | 是否在触发器或下拉面板尺寸变化时更新下拉面板位置,面板尺寸变化参见级联选择器,默认 `true` |`true` `false` |
|
| autoFixPosition | 是否在触发器或下拉面板尺寸变化时更新下拉面板位置,<br>面板尺寸变化参见级联选择器,默认 `true` |`true` `false` |
|
||||||
| clickToClose | 是否在点击触发器时关闭面板 |`true` `false`|
|
| clickToClose | 是否在点击触发器时关闭面板,默认 `true` |`true` `false`|
|
||||||
| blurToClose | 是否在触发器失去焦点时关闭面板 |`true` `false`|
|
| blurToClose | 是否在触发器失去焦点时关闭面板,默认 `true` |`true` `false`|
|
||||||
| clickOutsideToClose| 是否点击外部关闭下拉面板,默认 `true`|`true` `false`|
|
| clickOutsideToClose| 是否点击外部关闭下拉面板,默认 `true`|`true` `false`|
|
||||||
| contentOffset | 下拉面板距离触发器的偏移距离,默认 2| -|
|
| contentOffset | 下拉面板距离触发器的偏移距离,默认 2| -|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user