mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-29 13:42:54 +08:00
feat: 增加清空搜索框的按钮 #18
This commit is contained in:
parent
d5f5d123d5
commit
bc7d869a3b
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="clip-search">
|
<div class="clip-search">
|
||||||
<input v-model="filterText" type="text" placeholder="🔍 检索剪贴板历史" />
|
<input v-model="filterText" type="text" placeholder="🔍 检索剪贴板历史" />
|
||||||
|
<span v-show="filterText" @click="clear" class="clip-search-suffix">✖</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -16,11 +17,14 @@ const filterText = ref('')
|
|||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
// filterText变了 通知父组件修改 modelValue的值
|
// filterText变了 通知父组件修改 modelValue的值
|
||||||
watch(filterText, (val) => emit('update:modelValue', val))
|
watch(filterText, (val) => emit('update:modelValue', val))
|
||||||
|
|
||||||
// modelValue变了 更新 filterText的值
|
// modelValue变了 更新 filterText的值
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(val) => (filterText.value = val)
|
(val) => (filterText.value = val)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const clear = () => emit('update:modelValue', '')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -18,4 +18,20 @@
|
|||||||
color: @text-color-lighter;
|
color: @text-color-lighter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.clip-search-suffix {
|
||||||
|
text-align: center;
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
top: 18px;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 2px;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background-color: @nav-bg-color;
|
||||||
|
border-radius: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
background-color: @nav-hover-bg-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user