Browse Source

Merge branch 'next' of https://github.com/jdf2e/nutui into next

Drjingfubo 4 years ago
parent
commit
11557e64b1
2 changed files with 15 additions and 10 deletions
  1. 7 4
      src/packages/__VUE/tab/index.taro.vue
  2. 8 6
      src/packages/__VUE/tab/index.vue

+ 7 - 4
src/packages/__VUE/tab/index.taro.vue

@@ -196,10 +196,13 @@ export default create({
       for (let i = 0; i < 100; i++) arrnew.push(i);
       arr.value = arrnew;
     });
-    watchEffect(
-      () => (ctx.slots.default ? ctx.slots.default() : ''),
-      () => {
-        initTitle();
+    watch(
+      () => ctx.slots.default(),
+      (val, oldVal) => {
+        if (val) {
+          ctx.slots.default();
+          initTitle();
+        }
       }
     );
     watchEffect(() => {

+ 8 - 6
src/packages/__VUE/tab/index.vue

@@ -140,7 +140,6 @@ export default create({
       nutuiSwiper.value.to(index);
     }
     function initTitle() {
-      console.log(11);
       titles.length = 0;
       if (ctx.slots.default) {
         const slots: VNode[] =
@@ -166,10 +165,13 @@ export default create({
     onMounted(() => {
       initTitle();
     });
-    watchEffect(
-      () => (ctx.slots.default ? ctx.slots.default() : ''),
-      () => {
-        initTitle();
+    watch(
+      () => ctx.slots.default(),
+      (val, oldVal) => {
+        if (val) {
+          ctx.slots.default();
+          initTitle();
+        }
       }
     );
     watchEffect(() => {
@@ -178,7 +180,7 @@ export default create({
     watch(
       () => activeIndex.value,
       (val, oldVal) => {
-        ictx.emit('switch-tab', activeIndex.value);
+        ctx.emit('switch-tab', activeIndex.value);
       }
     );
     return {