Skip to content

Commit

Permalink
fix: 修复 select 不显示 icon 问题和文档
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Jun 17, 2024
1 parent 4da58ed commit 996c2b9
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 14 deletions.
80 changes: 71 additions & 9 deletions docs/components/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@

:::

## 过滤 & 筛选
## 过滤和筛选

开启 `filter` 后,选择器则按输入值过滤选项。

::: demo

<template #source>
<f-select filter v-model="value5" placeholder="请选择……" clear>
<f-option :value="1">香蕉</f-option>
<f-option :value="2">苹果</f-option>
<f-option :value="3">哈密瓜</f-option>
<f-option :value="4">樱桃</f-option>
</f-select>
<f-select filter v-model="value5" placeholder="请选择……" clear>
<f-option :value="1">香蕉</f-option>
<f-option :value="2">苹果</f-option>
<f-option :value="3">哈密瓜</f-option>
<f-option :value="4">樱桃</f-option>
</f-select>
</template>

```html
Expand All @@ -179,10 +179,72 @@
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const value = ref()
import { ref } from 'vue'
const value = ref()
</script>
```

:::

::: demo

<template #source>
<f-alert type="default" simple round>如果你需要携带一些参数传递,可以参考下面代码实现方式:</f-alert>
</template>

```html
<script lang="ts" setup>
import { ref } from 'vue'
import { FConfirmBox } from 'fighting-design'
import type { SelectModelValue } from 'fighting-design'
const list = [1, 2, 3, 4]
const selectValue = ref<SelectModelValue>('')
const load = () => {
return new Promise(resolve => {
setTimeout(() => {
resolve(true)
}, 2000)
})
}
const oneforeChange = (item: number, value: SelectModelValue) => {
return ((): Promise<boolean> => {
return new Promise(resolve => {
FConfirmBox({
title: '提示',
content: `你确定修改${item}的状态吗?`,
zIndex: 2000,
onConfirm: async () => {
await load()
selectValue.value = value
resolve(true)
},
onCancel: () => {
resolve(false)
}
})
})
})()
}
</script>

<template>
<h1>{{ selectValue || '未选择' }}</h1>
<div v-for="(item, index) in list" :key="index">
<f-select
v-model="selectValue"
placeholder="请选择……"
:on-before-change="(value: SelectModelValue) => oneforeChange(item, value) "
>
<f-option value="0">未发布</f-option>
<f-option value="1">已发布</f-option>
</f-select>
</div>
</template>
```

:::
Expand Down
9 changes: 4 additions & 5 deletions packages/fighting-design/select/src/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
provide<SelectProvide>(
SELECT_PROPS_TOKEN,
reactive({
setValue,
inputValue,
isFiltering,
onBeforeChange: prop.onBeforeChange,
modelValue,
filter: prop.filter
filter: prop.filter,
setValue,
onBeforeChange: prop.onBeforeChange
})
)
</script>
Expand All @@ -143,9 +143,8 @@
:on-blur="inputBlur"
:on-input="filter ? inputInput : void 0"
>
<template #after="{ isHover }">
<template #after>
<f-svg-icon
v-if="!isHover && filter && isFiltering"
color="#bababa"
:class="['f-select__arrow', { 'f-select__arrow-active': isFocus }]"
:size="13"
Expand Down

0 comments on commit 996c2b9

Please sign in to comment.