1919 </template >
2020
2121 <v-card >
22- <v-card-text style = " padding : 0 ; " >
22+ <v-card-text class = " px-0 py-0 " >
2323 <v-tabs fixed-tabs v-model =" activeTab" >
2424 <v-tab key =" calendar" >
2525 <slot name =" dateIcon" >
@@ -126,21 +126,8 @@ export default {
126126 time: DEFAULT_TIME
127127 }
128128 },
129- created () {
130- if (! this .datetime ) {
131- return
132- }
133-
134- let initDateTime
135- if (this .datetime instanceof Date ) {
136- initDateTime = this .datetime
137- } else if (typeof this .datetime === ' string' || this .datetime instanceof String ) {
138- // see https://stackoverflow.com/a/9436948
139- initDateTime = parse (this .datetime , this .dateTimeFormat , new Date ())
140- }
141-
142- this .date = format (initDateTime, DEFAULT_DATE_FORMAT )
143- this .time = format (initDateTime, DEFAULT_TIME_FORMAT )
129+ mounted () {
130+ this .init ()
144131 },
145132 computed: {
146133 dateTimeFormat () {
@@ -168,6 +155,22 @@ export default {
168155 }
169156 },
170157 methods: {
158+ init () {
159+ if (! this .datetime ) {
160+ return
161+ }
162+
163+ let initDateTime
164+ if (this .datetime instanceof Date ) {
165+ initDateTime = this .datetime
166+ } else if (typeof this .datetime === ' string' || this .datetime instanceof String ) {
167+ // see https://stackoverflow.com/a/9436948
168+ initDateTime = parse (this .datetime , this .dateTimeFormat , new Date ())
169+ }
170+
171+ this .date = format (initDateTime, DEFAULT_DATE_FORMAT )
172+ this .time = format (initDateTime, DEFAULT_TIME_FORMAT )
173+ },
171174 okHandler () {
172175 this .resetPicker ()
173176 this .$emit (' input' , this .selectedDatetime )
@@ -188,6 +191,11 @@ export default {
188191 showTimePicker () {
189192 this .activeTab = 1
190193 }
194+ },
195+ watch: {
196+ datetime : function () {
197+ this .init ()
198+ }
191199 }
192200}
193201 </script >
0 commit comments