lifanagju_citu 1 rok temu
rodzic
commit
5c64009ab0
1 zmienionych plików z 10 dodań i 6 usunięć
  1. 10 6
      src/components/headSearch/index.vue

+ 10 - 6
src/components/headSearch/index.vue

@@ -17,7 +17,7 @@
       class="px-2"
       style="height: 100%; line-height: 100%;"
     ></v-text-field>
-    <div class="searchBtn">搜索</div>
+    <div class="searchBtn" @click="handleSearch">搜索</div>
   </div>
 </template>
 
@@ -25,9 +25,11 @@
 import { useSharedState } from '@/store/sharedState'
 import jobTypeCard from '@/components/jobTypeCard'
 import { ref, watch } from 'vue'
-// import { useRouter } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 defineOptions({ name:'common-components-headSearch'})
-// const router = useRouter()
+const route = useRoute(); const router = useRouter()
+const emits = defineEmits(['handleSearch'])// 定义一个或多个自定义事件
+
 const text = ref('职位类型')
 const value = ref('')
 let drawer = ref(false)
@@ -38,9 +40,11 @@ watch(() => sharedState.layoutClickCount, () => {
   if (drawer.value) drawer.value = false
 });
 
-// const jobClick = (jobInfo) => {
-//   router.push({ path: '/recruit/position',query: jobInfo })
-// }
+const handleSearch = () => {
+  const path = '/recruit/position'
+  if (path === route.path) emits('handleSearch', {})
+  else router.push({ path: '/recruit/position',query: {} })
+}
 
 </script>