fix bug: default-sort-prop is not defined but trigger sort-change event

pull/2309/head
njleonzhang 2017-01-09 23:04:06 +08:00
parent 48996c6658
commit 59d1f49b1c
1 changed files with 13 additions and 11 deletions

View File

@ -190,20 +190,22 @@ export default {
},
mounted() {
const states = this.store.states;
states.sortProp = this.defaultSortProp;
states.sortOrder = this.defaultSortOrder;
if (this.defaultSortProp) {
const states = this.store.states;
states.sortProp = this.defaultSortProp;
states.sortOrder = this.defaultSortOrder;
this.$nextTick(_ => {
for (let i = 0, length = this.columns.length; i < length; i++) {
if (this.columns[i].property === this.defaultSortProp) {
this.columns[i].order = this.defaultSortOrder;
break;
this.$nextTick(_ => {
for (let i = 0, length = this.columns.length; i < length; i++) {
if (this.columns[i].property === this.defaultSortProp) {
this.columns[i].order = this.defaultSortOrder;
break;
}
}
}
this.store.commit('changeSortCondition');
});
this.store.commit('changeSortCondition');
});
}
},
beforeDestroy() {