ソースを参照

fix: calendar组件增加监听默认值修改功能

songchenglin3 5 年 前
コミット
146d0d2af7
1 ファイル変更10 行追加2 行削除
  1. 10 2
      src/packages/calendar/calendar.vue

+ 10 - 2
src/packages/calendar/calendar.vue

@@ -83,6 +83,14 @@ export default {
   watch: {
   watch: {
     isVisible(newValue, oldValue) {
     isVisible(newValue, oldValue) {
       this.childIsVisible = newValue;
       this.childIsVisible = newValue;
+    },
+    defaultValue: {
+      handler(oldValue, val) {
+        if (val) {
+          this.resetRender();
+        }
+      },
+      immediate: true
     }
     }
   },
   },
   data() {
   data() {
@@ -102,8 +110,6 @@ export default {
       transformY: 0,
       transformY: 0,
       scrollDistance: 0,
       scrollDistance: 0,
       defaultData: null,
       defaultData: null,
-      startData: this.startDate ? this.splitDate(this.startDate) : null,
-      endData: this.endDate ? this.splitDate(this.endDate) : null,
       chooseData: [],
       chooseData: [],
       monthsData: [],
       monthsData: [],
       dayPrefix: 'nut-calendar-month-day'
       dayPrefix: 'nut-calendar-month-day'
@@ -387,6 +393,8 @@ export default {
     },
     },
 
 
     initData() {
     initData() {
+      this.startData = this.startDate ? this.splitDate(this.startDate) : null;
+      this.endData = this.endDate ? this.splitDate(this.endDate) : null;
       if (!this.defaultValue) {
       if (!this.defaultValue) {
         this.currDate = this.isRange ? [Utils.date2Str(new Date()), Utils.getDay(2)] : Utils.date2Str(new Date());
         this.currDate = this.isRange ? [Utils.date2Str(new Date()), Utils.getDay(2)] : Utils.date2Str(new Date());
       } else {
       } else {