Przeglądaj źródła

修改页面BUG

wyling 3 lat temu
rodzic
commit
31c362dff9
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8 3
      src/views/home/children/test/index.vue

+ 8 - 3
src/views/home/children/test/index.vue

@@ -43,14 +43,19 @@
 <script lang="ts" setup>
 import sujectOne from "./components/sujectOne.vue";
 import userData from "./components/userData.vue";
-import { ref, nextTick } from "vue";
+import { ref, nextTick, onBeforeMount } from "vue";
 import { useStore } from "vuex";
 const store = useStore();
 
 const carTypeRef = ref<any>(null);
-nextTick(() => {
-  carTypeRef.value.scrollTo(store.state.carType);
+onBeforeMount(() => {
+  nextTick(() => {
+    try {
+      carTypeRef.value.scrollTo(store.state.carType);
+    } catch (error) {}
+  });
 });
+
 const carTypeChange = (e: string) => {
   store.commit("setCatType", e);
 };