From 5d65ef91831d4bf4e440da3f2f97284a78f9cdda Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Sun, 29 Aug 2021 13:29:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9d-search=20?= =?UTF-8?q?=E6=A0=B7=E5=BC=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/search/src/search.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/devui/search/src/search.scss b/devui/search/src/search.scss index 0e7d66aa..0e5c186a 100644 --- a/devui/search/src/search.scss +++ b/devui/search/src/search.scss @@ -41,6 +41,7 @@ cursor: pointer; padding: 0 10px; position: absolute; + z-index: 1; right: 0; top: 0; font-size: 16px; -- Gitee From cf459312070bf87d45f83a89127f7afe6fecb5d1 Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Sun, 29 Aug 2021 14:23:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=BB=84=E4=BB=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=20searchFn=20=E4=BC=A0=E9=80=92=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E8=BE=93=E5=85=A5=E6=A1=86=E6=89=A7=E8=A1=8C?= =?UTF-8?q?update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/search/hooks/use-search-keywords.ts | 7 +++++-- devui/search/src/search-types.ts | 4 ++++ devui/search/src/search.tsx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/devui/search/hooks/use-search-keywords.ts b/devui/search/hooks/use-search-keywords.ts index 23fdd061..d0feccc8 100644 --- a/devui/search/hooks/use-search-keywords.ts +++ b/devui/search/hooks/use-search-keywords.ts @@ -1,10 +1,11 @@ /** * 输入框内容定义、删改操作 */ -import { ref, watch, computed } from 'vue' +import { ref, watch, computed, SetupContext } from 'vue' import { SearchProps, KeywordsReturnTypes } from '../src/search-types' +type EmitProps = 'update:modelValue' | 'searchFn' -export const keywordsHandles = (props: SearchProps): KeywordsReturnTypes => { +export const keywordsHandles = (ctx: SetupContext<(EmitProps)[]>, props: SearchProps): KeywordsReturnTypes => { const keywords = ref('') // 输入框内容 // 监听是否有双向绑定,将绑定的值传递给keyword,因为需要清除输入框 watch(() => props.modelValue, (val)=> { @@ -13,6 +14,8 @@ export const keywordsHandles = (props: SearchProps): KeywordsReturnTypes => { // 清空输入框 const onClearHandle = () => { keywords.value = '' + // 清空输入框时更新modelValue为空 + ctx.emit('update:modelValue', '') } const clearIconShow = computed(() => { return keywords.value.length > 0 diff --git a/devui/search/src/search-types.ts b/devui/search/src/search-types.ts index 2462f1c3..6d42d532 100644 --- a/devui/search/src/search-types.ts +++ b/devui/search/src/search-types.ts @@ -48,6 +48,10 @@ export const searchProps = { type: String, default: '', }, + searchFn: { + type: Function as PropType<(v: string) => void>, + default: undefined + }, 'onUpdate:modelValue': { type: Function as PropType<(v: string) => void>, default: undefined diff --git a/devui/search/src/search.tsx b/devui/search/src/search.tsx index 1b8ccccc..e2ca607e 100644 --- a/devui/search/src/search.tsx +++ b/devui/search/src/search.tsx @@ -13,7 +13,7 @@ export default defineComponent({ setup(props: SearchProps, ctx) { const rootClasses = getRootClass(props) // 输入框内容定义、删改 - const {keywords, clearIconShow, onClearHandle} = keywordsHandles(props) + const {keywords, clearIconShow, onClearHandle} = keywordsHandles(ctx, props) // 键盘回车事件 const { onInputKeydown, onClickHandle } = keydownHandles(ctx, keywords) -- Gitee