Commit 5246b170 authored by baiyaaaaa's avatar baiyaaaaa Committed by GitHub

Merge pull request #2309 from njleonzhang/fix_sortevent_bug

fix bug: default-sort-prop is not defined but trigger sort-change event
parents 9f94a28f 22cea4e6
...@@ -190,20 +190,26 @@ export default { ...@@ -190,20 +190,26 @@ export default {
}, },
mounted() { mounted() {
const states = this.store.states; if (this.defaultSortProp) {
states.sortProp = this.defaultSortProp; const states = this.store.states;
states.sortOrder = this.defaultSortOrder; states.sortProp = this.defaultSortProp;
states.sortOrder = this.defaultSortOrder;
this.$nextTick(_ => {
for (let i = 0, length = this.columns.length; i < length; i++) { this.$nextTick(_ => {
if (this.columns[i].property === this.defaultSortProp) { for (let i = 0, length = this.columns.length; i < length; i++) {
this.columns[i].order = this.defaultSortOrder; let column = this.columns[i];
break; if (column.property === this.defaultSortProp) {
column.order = this.defaultSortOrder;
states.sortingColumn = column;
break;
}
} }
}
this.store.commit('changeSortCondition'); if (states.sortingColumn) {
}); this.store.commit('changeSortCondition');
}
});
}
}, },
beforeDestroy() { beforeDestroy() {
......
...@@ -1127,7 +1127,7 @@ describe('Table', () => { ...@@ -1127,7 +1127,7 @@ describe('Table', () => {
} }
}, '@sort-change="sortChange"'); }, '@sort-change="sortChange"');
setTimeout(_ => { setTimeout(_ => {
const elm = vm.$el.querySelector('.caret-wrapper > .ascending'); const elm = vm.$el.querySelector('.caret-wrapper');
elm.click(); elm.click();
setTimeout(_ => { setTimeout(_ => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment