diff --git a/packages/table/src/table-header.js b/packages/table/src/table-header.js index 6fc3458ff..b78eabb62 100644 --- a/packages/table/src/table-header.js +++ b/packages/table/src/table-header.js @@ -210,7 +210,8 @@ export default { mounted() { const { prop, order } = this.defaultSort; - this.store.commit('sort', { prop, order }); + const init = true; + this.store.commit('sort', { prop, order, init }); }, beforeDestroy() { diff --git a/packages/table/src/table-store.js b/packages/table/src/table-store.js index f0ab5491b..54b7294af 100644 --- a/packages/table/src/table-store.js +++ b/packages/table/src/table-store.js @@ -259,7 +259,7 @@ TableStore.prototype.mutations = { changeSortCondition(states, options) { states.data = sortData((states.filteredData || states._data || []), states); - if (!options || !options.silent) { + if (!options || !(options.silent || options.init)) { this.table.$emit('sort-change', { column: this.states.sortingColumn, prop: this.states.sortProp, @@ -271,7 +271,7 @@ TableStore.prototype.mutations = { }, sort(states, options) { - const { prop, order } = options; + const { prop, order, init } = options; if (prop) { states.sortProp = prop; states.sortOrder = order || 'ascending'; @@ -286,7 +286,9 @@ TableStore.prototype.mutations = { } if (states.sortingColumn) { - this.commit('changeSortCondition'); + this.commit('changeSortCondition', { + init: init + }); } }); }