fixed some components bug that can not translate when using vue-i18n

This commit is contained in:
梁灏 2017-03-30 16:05:20 +08:00
parent ed91d9b0c7
commit e5337c810c
8 changed files with 185 additions and 153 deletions

View file

@ -1,55 +1,13 @@
<!-- <template>
<div :class="classes">
<List
ref="left"
:prefix-cls="prefixCls + '-list'"
:data="leftData"
:render-format="renderFormat"
:checked-keys="leftCheckedKeys"
@on-checked-keys-change="handleLeftCheckedKeysChange"
:valid-keys-count="leftValidKeysCount"
:style="listStyle"
:title="titles[0]"
:filterable="filterable"
:filter-placeholder="filterPlaceholder"
:filter-method="filterMethod"
:not-found-text="notFoundText">
<slot></slot>
</List>
<Operation
:prefix-cls="prefixCls"
:operations="operations"
:left-active="leftValidKeysCount > 0"
:right-active="rightValidKeysCount > 0">
</Operation>
<List
ref="right"
:prefix-cls="prefixCls + '-list'"
:data="rightData"
:render-format="renderFormat"
:checked-keys="rightCheckedKeys"
@on-checked-keys-change="handleRightCheckedKeysChange"
:valid-keys-count="rightValidKeysCount"
:style="listStyle"
:title="titles[1]"
:filterable="filterable"
:filter-placeholder="filterPlaceholder"
:filter-method="filterMethod"
:not-found-text="notFoundText">
<slot></slot>
</List>
</div>
</template> -->
<script>
import List from './list.vue';
import Operation from './operation.vue';
import { t } from '../../locale';
import Locale from '../../mixins/locale';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-transfer';
export default {
mixins: [ Emitter ],
mixins: [ Emitter, Locale ],
render (createElement) {
function cloneVNode (vnode) {
@ -82,11 +40,11 @@
checkedKeys: this.leftCheckedKeys,
validKeysCount: this.leftValidKeysCount,
style: this.listStyle,
title: this.titles[0],
title: this.localeTitles[0],
filterable: this.filterable,
filterPlaceholder: this.filterPlaceholder,
filterPlaceholder: this.localeFilterPlaceholder,
filterMethod: this.filterMethod,
notFoundText: this.notFoundText
notFoundText: this.localeNotFoundText
},
on: {
'on-checked-keys-change': this.handleLeftCheckedKeysChange
@ -111,11 +69,11 @@
checkedKeys: this.rightCheckedKeys,
validKeysCount: this.rightValidKeysCount,
style: this.listStyle,
title: this.titles[1],
title: this.localeTitles[1],
filterable: this.filterable,
filterPlaceholder: this.filterPlaceholder,
filterPlaceholder: this.localeFilterPlaceholder,
filterMethod: this.filterMethod,
notFoundText: this.notFoundText
notFoundText: this.localeNotFoundText
},
on: {
'on-checked-keys-change': this.handleRightCheckedKeysChange
@ -157,10 +115,7 @@
}
},
titles: {
type: Array,
default () {
return [t('i.transfer.titles.source'), t('i.transfer.titles.target')];
}
type: Array
},
operations: {
type: Array,
@ -173,10 +128,7 @@
default: false
},
filterPlaceholder: {
type: String,
default () {
return t('i.transfer.filterPlaceholder');
}
type: String
},
filterMethod: {
type: Function,
@ -186,10 +138,7 @@
}
},
notFoundText: {
type: String,
default () {
return t('i.transfer.notFoundText');
}
type: String
}
},
data () {
@ -212,6 +161,27 @@
},
rightValidKeysCount () {
return this.getValidKeys('right').length;
},
localeFilterPlaceholder () {
if (this.filterPlaceholder === undefined) {
return this.t('i.transfer.filterPlaceholder');
} else {
return this.filterPlaceholder;
}
},
localeNotFoundText () {
if (this.notFoundText === undefined) {
return this.t('i.transfer.notFoundText');
} else {
return this.notFoundText;
}
},
localeTitles () {
if (this.titles === undefined) {
return [this.t('i.transfer.titles.source'), this.t('i.transfer.titles.target')];
} else {
return this.titles;
}
}
},
methods: {