Commit 22c27b7962a5363cadcf14fda9b51965fb42cbdf

Authored by 梁灏
1 parent b142865e

fixed #2215

examples/routers/date.vue
1   -<template>
2   - <div>
3   - {{ value1 }}
4   - <Date-picker v-model="value1" type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="hc"></Date-picker>
5   - <Button @click="setDate">set date</Button>
6   - <Button @click="getDate">get date</Button>
7   - <!--<Date-picker v-model="value2" type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker>-->
8   - <!--<Date-picker transfer type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="changeDate"></Date-picker>-->
9   - </div>
10   -</template>
11   -<script>
12   - export default {
13   - data () {
14   - return {
15   - value1: ['2014-10-10 10:00:01', '2017-10-10 10:00:00'],
16   - value2: []
17   - }
18   - },
19   - methods: {
20   - changeDate(date){
21   - console.log(date);
22   - },
23   - setDate () {
24   - this.value1 = ['2016-10-10', '2017-10-10'];
25   - },
26   - getDate () {
27   - const date = new Date(this.value1);
28   - console.log(date.getMonth()+1)
29   - },
30   - hc (d) {
31   - console.log(d);
32   - }
33   - }
34   - }
35   -</script>
36   -<style>
37   - body{
38   - width: 100%;
39   - }
40   -</style>
  1 +<!--<template>-->
  2 + <!--<div>-->
  3 + <!--{{ value1 }}-->
  4 + <!--<Date-picker v-model="value1" type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="hc"></Date-picker>-->
  5 + <!--<Button @click="setDate">set date</Button>-->
  6 + <!--<Button @click="getDate">get date</Button>-->
  7 + <!--&lt;!&ndash;<Date-picker v-model="value2" type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker>&ndash;&gt;-->
  8 + <!--&lt;!&ndash;<Date-picker transfer type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="changeDate"></Date-picker>&ndash;&gt;-->
  9 + <!--</div>-->
  10 +<!--</template>-->
  11 +<!--<script>-->
  12 + <!--export default {-->
  13 + <!--data () {-->
  14 + <!--return {-->
  15 + <!--value1: ['2014-10-10 10:00:01', '2017-10-10 10:00:00'],-->
  16 + <!--value2: []-->
  17 + <!--}-->
  18 + <!--},-->
  19 + <!--methods: {-->
  20 + <!--changeDate(date){-->
  21 + <!--console.log(date);-->
  22 + <!--},-->
  23 + <!--setDate () {-->
  24 + <!--this.value1 = ['2016-10-10', '2017-10-10'];-->
  25 + <!--},-->
  26 + <!--getDate () {-->
  27 + <!--const date = new Date(this.value1);-->
  28 + <!--console.log(date.getMonth()+1)-->
  29 + <!--},-->
  30 + <!--hc (d) {-->
  31 + <!--console.log(d);-->
  32 + <!--}-->
  33 + <!--}-->
  34 + <!--}-->
  35 +<!--</script>-->
  36 +<!--<style>-->
  37 + <!--body{-->
  38 + <!--width: 100%;-->
  39 + <!--}-->
  40 +<!--</style>-->
41 41  
42 42  
43 43 <!--<template>-->
... ... @@ -189,3 +189,22 @@
189 189  
190 190  
191 191  
  192 +<template>
  193 + <div>
  194 + <DatePicker v-model="value" @on-change="handleChange" type="date" placeholder="Select date" style="width: 200px"></DatePicker>
  195 + </div>
  196 +</template>
  197 +<script>
  198 + export default {
  199 + data () {
  200 + return {
  201 + value: new Date()
  202 + }
  203 + },
  204 + methods: {
  205 + handleChange (v) {
  206 + console.log(v);
  207 + }
  208 + }
  209 + }
  210 +</script>
... ...
src/components/date-picker/picker.vue
... ... @@ -404,6 +404,10 @@
404 404 this.currentValue = '';
405 405 this.$emit('on-clear');
406 406 this.dispatch('FormItem', 'on-form-change', '');
  407 + // #2215,当初始设置了 value,直接点 clear,这时 this.picker 还没有加载
  408 + if (!this.picker) {
  409 + this.emitChange('');
  410 + }
407 411 },
408 412 showPicker () {
409 413 if (!this.picker) {
... ...