fix: 🐛 修复search组件suffix插槽无法使用的问题

This commit is contained in:
WenXu 2024-04-04 17:35:17 +08:00 committed by 不如摸鱼去
parent 5fb9542087
commit 6a4af41b93
3 changed files with 20 additions and 20 deletions

View File

@ -156,19 +156,19 @@ function changeSearchType({ item, index }) {
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
| ---------------- | ------------------------------------- | --------------- | ------ | ------ | -------- |
| placeholder | 搜索框占位文本 | string | - | 搜索 | - |
| placeholder-left | placeholder 居左边 | boolean | - | false | - |
| cancel-txt | 搜索框右侧文本 | string | - | 取消 | - |
| light | 搜索框亮色(白色) | boolean | - | false | - |
| hide-cancel | 是否隐藏右侧文本 | boolean | - | false | - |
| disabled | 是否禁用搜索框 | boolean | - | false | - |
| maxlength | 原生属性,设置最大长度。-1 表示无限制 | string / number | - | -1 | - |
| v-model | 输入框内容,双向绑定 | string | - | - | - |
| use-suffix-slot | 是否使用输入框右侧插槽 | boolean | - | false | - |
| focus | 是否自动聚焦 | boolean | - | false | 0.1.63 |
| focusWhenClear | 是否在点击清除按钮时聚焦输入框 | boolean | - | false | 0.1.63 |
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
| ------------------- | ----------------------------------------------------------------------------------------- | --------------- | ------ | ------ | -------- |
| placeholder | 搜索框占位文本 | string | - | 搜索 | - |
| placeholder-left | placeholder 居左边 | boolean | - | false | - |
| cancel-txt | 搜索框右侧文本 | string | - | 取消 | - |
| light | 搜索框亮色(白色) | boolean | - | false | - |
| hide-cancel | 是否隐藏右侧文本 | boolean | - | false | - |
| disabled | 是否禁用搜索框 | boolean | - | false | - |
| maxlength | 原生属性,设置最大长度。-1 表示无限制 | string / number | - | -1 | - |
| v-model | 输入框内容,双向绑定 | string | - | - | - |
| ~~use-suffix-slot~~ | ~~是否使用输入框右侧插槽~~**(已废弃,将在下一个 minor 版本被移除,直接使用插槽即可)** | boolean | - | false | - |
| focus | 是否自动聚焦 | boolean | - | false | 0.1.63 |
| focusWhenClear | 是否在点击清除按钮时聚焦输入框 | boolean | - | false | 0.1.63 |
## Events
@ -186,7 +186,7 @@ function changeSearchType({ item, index }) {
| name | 说明 | 最低版本 |
| ------ | -------------------- | -------- |
| prefix | 输入框左侧自定义内容 | - |
| suffix | 输入框侧自定义内容 | - |
| suffix | 输入框侧自定义内容 | - |
## 外部样式类

View File

@ -14,8 +14,9 @@ export const searchProps = {
* 使
* 类型: boolean
* 默认值: false
* @deprecated minor版本被移除使
*/
userSuffixSlot: makeBooleanProp(false),
useSuffixSlot: makeBooleanProp(false),
/**
*

View File

@ -32,14 +32,13 @@
</view>
</view>
<!--the button behind input,care for hideCancel without displaying-->
<block v-if="!hideCancel">
<!--有插槽就不用默认的按钮了-->
<slot v-if="userSuffixSlot" name="suffix"></slot>
<slot v-if="!hideCancel" name="suffix">
<!--默认button-->
<view v-else class="wd-search__cancel" @click="handleCancel">
<view class="wd-search__cancel" @click="handleCancel">
{{ cancelTxt || translate('cancel') }}
</view>
</block>
</slot>
</view>
</template>