浏览代码

搜索bug

jwyu 3 年之前
父节点
当前提交
effb948475
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/components/Search.vue

+ 8 - 1
src/components/Search.vue

@@ -1,5 +1,5 @@
 <script setup>
 <script setup>
-import { computed, ref } from "vue";
+import { computed, ref, watch } from "vue";
 const props=defineProps({
 const props=defineProps({
   defaultVal:{
   defaultVal:{
     type:String,
     type:String,
@@ -43,6 +43,13 @@ const handleSearch = ()=>{
   }
   }
   emit('search',searchData.value)
   emit('search',searchData.value)
 }
 }
+
+watch(
+  ()=>props.defaultVal,
+  ()=>{
+    searchData.value=props.defaultVal
+  }
+)
 </script>
 </script>
 <template>
 <template>
   <div :class="['search-wrap',(isFocus||searchData)&&'focus']">
   <div :class="['search-wrap',(isFocus||searchData)&&'focus']">