Sfoglia il codice sorgente

Merge pull request #334 from QingWei-Li/fix/datepicker-i18n

DatePicker: fix i18n
baiyaaaaa 8 anni fa
parent
commit
96b9604a43

+ 3 - 1
packages/date-picker/src/panel/date-range.vue

@@ -302,7 +302,9 @@
     },
 
     methods: {
-      $t,
+      $t(...args) {
+        return $t.apply(this, args);
+      },
 
       closeLeftTimePicker() {
         this.leftTimePickerVisible = false;

+ 6 - 1
packages/date-picker/src/panel/time-range.vue

@@ -48,8 +48,9 @@
   </transition>
 </template>
 
-<script type="text/ecmascript-6">
+<script type="text/babel">
   import { parseDate, limitRange } from '../util';
+  import { $t } from '../util';
 
   const MIN_TIME = parseDate('00:00:00', 'HH:mm:ss');
   const MAX_TIME = parseDate('23:59:59', 'HH:mm:ss');
@@ -95,6 +96,10 @@
     },
 
     methods: {
+      $t(...args) {
+        return $t.apply(this, args);
+      },
+
       handleCancel() {
         this.$emit('pick');
       },

+ 1 - 1
packages/date-picker/src/panel/time-select.vue

@@ -16,7 +16,7 @@
   </transition>
 </template>
 
-<script type="text/ecmascript-6">
+<script type="text/babel">
   const parseTime = function(time) {
     const values = ('' || time).split(':');
     if (values.length >= 2) {

+ 5 - 0
packages/date-picker/src/panel/time.vue

@@ -31,6 +31,7 @@
 <script type="text/babel">
   import { limitRange } from '../util';
   import Vue from 'vue';
+  import { $t } from '../util';
 
   export default {
     components: {
@@ -91,6 +92,10 @@
     },
 
     methods: {
+      $t(...args) {
+        return $t.apply(this, args);
+      },
+
       handleCancel() {
         this.$emit('pick', null);
       },

+ 1 - 1
src/mixins/emitter.js

@@ -12,7 +12,7 @@ function broadcast(componentName, eventName, params) {
 export default {
   methods: {
     dispatch(componentName, eventName, params) {
-      var parent = this.$parent;
+      var parent = this.$parent || this.$root;
       var name = parent.$options.componentName;
 
       while (parent && (!name || name !== componentName)) {