Bläddra i källkod

feat: scrollbar

gemercheung 1 år sedan
förälder
incheckning
2bc2d1d410
1 ändrade filer med 16 tillägg och 8 borttagningar
  1. 16 8
      packages/qjkankan-kankan-view/src/components/Controls/tours.mobile.vue

+ 16 - 8
packages/qjkankan-kankan-view/src/components/Controls/tours.mobile.vue

@@ -124,16 +124,24 @@ const isPlay = computed(() => {
   return status;
 });
 const isInit = ref(false);
-const tours = computed(() => {
-  let tours = store.getters["tour/tours"];
-  if (tours.length > 0) {
-    if (tourScroll.value && !isInit.value) {
-      isInit.value = true;
-      new Scrollbar(tourScroll.value, { onlyHorizontal: true });
+const tours = computed(() => store.getters["tour/tours"]);
+
+watch(
+  [tours, tourScroll],
+  (val) => {
+    if (val[0].length > 0 && val[1]) {
+      if (!isInit.value) {
+        isInit.value = true;
+        new Scrollbar(tourScroll.value, { onlyHorizontal: true });
+        console.log("init-Scrollbar");
+      }
     }
+  },
+  {
+    immediate: true,
+    deep: true,
   }
-  return tours;
-});
+);
 const onModeChange = (name) => {
   store.commit("setMode", name);
 };