mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-10-25 22:51:19 +08:00
feat: 增加清空搜索框的按钮 #18
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="clip-search">
|
||||
<input v-model="filterText" type="text" placeholder="🔍 检索剪贴板历史" />
|
||||
<span v-show="filterText" @click="clear" class="clip-search-suffix">✖</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -16,11 +17,14 @@ const filterText = ref('')
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
// filterText变了 通知父组件修改 modelValue的值
|
||||
watch(filterText, (val) => emit('update:modelValue', val))
|
||||
|
||||
// modelValue变了 更新 filterText的值
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => (filterText.value = val)
|
||||
)
|
||||
|
||||
const clear = () => emit('update:modelValue', '')
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user