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

@ -8,20 +8,20 @@
:multiple="multiple"
:show-checkbox="showCheckbox">
</Tree-node>
<div :class="[prefixCls + '-empty']" v-if="!data.length">{{ emptyText }}</div>
<div :class="[prefixCls + '-empty']" v-if="!data.length">{{ localeEmptyText }}</div>
</div>
</template>
<script>
import TreeNode from './node.vue';
import { findComponentsDownward } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
import { t } from '../../locale';
import Locale from '../../mixins/locale';
const prefixCls = 'ivu-tree';
export default {
name: 'Tree',
mixins: [ Emitter ],
mixins: [ Emitter, Locale ],
components: { TreeNode },
props: {
data: {
@ -39,10 +39,7 @@
default: false
},
emptyText: {
type: String,
default () {
return t('i.tree.emptyText');
}
type: String
}
},
data () {
@ -50,6 +47,15 @@
prefixCls: prefixCls
};
},
computed: {
localeEmptyText () {
if (this.emptyText === undefined) {
return this.t('i.tree.emptyText');
} else {
return this.emptyText;
}
}
},
methods: {
getSelectedNodes () {
const nodes = findComponentsDownward(this, 'TreeNode');