Browse Source

fix: 官网搜索栏回车跳转修复

Drjnigfubo 4 years ago
parent
commit
81c3e40b5e
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/sites/doc/components/Search.vue

+ 3 - 1
src/sites/doc/components/Search.vue

@@ -27,9 +27,11 @@
 <script>
 <script>
 import { defineComponent, reactive, onMounted, watch } from 'vue';
 import { defineComponent, reactive, onMounted, watch } from 'vue';
 import { nav } from '@/config.json';
 import { nav } from '@/config.json';
+import { useRouter } from 'vue-router';
 export default defineComponent({
 export default defineComponent({
   name: 'search',
   name: 'search',
   setup() {
   setup() {
+    const router = useRouter();
     const data = reactive({
     const data = reactive({
       nav,
       nav,
       navList: [],
       navList: [],
@@ -99,7 +101,7 @@ export default defineComponent({
           data.searchCurName = cName;
           data.searchCurName = cName;
           data.searchIndex = searchIndex;
           data.searchIndex = searchIndex;
           if (e.keyCode == 13) {
           if (e.keyCode == 13) {
-            data.$router.push({
+            router.push({
               path: '/' + searchList[searchIndex].name
               path: '/' + searchList[searchIndex].name
             });
             });
             data.searchCurName = '';
             data.searchCurName = '';