antdesign vue3 a-input-search 清空

<template>
  <a-input-search
    v-model:value="searchText"
    allow-clear
    @search="onSearch"
    @clear="clearSearch"
    placeholder="请输入"
  />
  <a-button @click="clearSearch">清空</a-button>
</template>
 
<script setup>
import { ref } from 'vue';
 
const searchText = ref('');
 
const onSearch = (value) => {
  console.log('Search:', value);
};
 
const clearSearch = () => {
  searchText.value = '';
};
</script>
 v-model:value="searchText" v-model:value是关键
searchText.value = '';一直没反应就是因为写成v-model=""
 实际上是v-model:value=""
 
posted @ 2024-03-21 15:07  luckylou  阅读(621)  评论(0编辑  收藏  举报