lizi 2 years ago
parent
commit
cf1214cea2
1 changed files with 19 additions and 2 deletions
  1. 19 2
      src/views/search/SearchView.vue

+ 19 - 2
src/views/search/SearchView.vue

@@ -1,11 +1,12 @@
 <script setup lang="ts">
 import { message, type SelectProps } from "ant-design-vue";
-import { ref } from "vue";
+import { ref, watch } from "vue";
 import { routeToSearch } from "@/router";
 
 const keyword = ref("");
 
 const field = ref("TP");
+const placeholder = ref("请输入文献主题") 
 
 const onSearch = () => {
   const kwd = keyword.value.trim();
@@ -23,6 +24,22 @@ const fieldOptions = ref<SelectProps['options']>([
   { value: 'KW', label: '关键词' },
   { value: 'AB', label: '摘要' },
 ]);
+
+watch(field, (newValue) => {
+  if (newValue == 'TI') {
+    placeholder.value = "请输入文献标题"
+  } else if (newValue == 'AU') {
+    placeholder.value = "请输入文献作者"
+  } else if (newValue == 'KW') {
+    placeholder.value = "请输入文献关键词"
+  } else if (newValue == 'AB') {
+    placeholder.value = "请输入文献摘要"
+  } else {
+    placeholder.value = "请输入文献主题"
+  }
+});
+
+
 </script>
 
 <template>
@@ -42,7 +59,7 @@ const fieldOptions = ref<SelectProps['options']>([
       <a-col flex="1">
         <a-input-search
           v-model:value="keyword"
-          placeholder="请输入关键词进行搜索"
+          :placeholder="placeholder"
           enter-button="搜&nbsp;&nbsp;索"
           size="large"
           @search="onSearch"