Browse Source

DatePicker: update view when setting default value, fixed #1050 (#1097)

cinwell.li 8 years ago
parent
commit
af4bca8abe
2 changed files with 3 additions and 3 deletions
  1. 2 2
      packages/date-picker/src/panel/date.vue
  2. 1 1
      test/unit/specs/date-picker.spec.js

+ 2 - 2
packages/date-picker/src/panel/date.vue

@@ -145,8 +145,8 @@
       },
 
       value(newVal) {
-        if (newVal instanceof Date) {
-
+        newVal = new Date(newVal);
+        if (!isNaN(newVal)) {
           if (typeof this.disabledDate === 'function' &&
             this.disabledDate(new Date(newVal))) {
             return;

+ 1 - 1
test/unit/specs/date-picker.spec.js

@@ -684,7 +684,7 @@ describe('DatePicker', () => {
       vm.picker.value = date;
 
       setTimeout(_ => {
-        expect(vm.picker.date === date).to.true;
+        expect(vm.picker.date.getTime() === date.getTime()).to.true;
         done();
       }, DELAY);
     });