Skip to content

Commit

Permalink
fix(table): useTable support onChange
Browse files Browse the repository at this point in the history
修复useTable无法直接通过设置onChange来注册change事件响应的问题
  • Loading branch information
mynetfan committed May 30, 2021
1 parent 9f4d171 commit 9f5085c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/Table/src/BasicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import { omit } from 'lodash-es';
import { basicProps } from './props';
import { isFunction } from '/@/utils/is';
export default defineComponent({
components: {
Expand Down Expand Up @@ -142,6 +143,9 @@
function handleTableChange(...args) {
onTableChange.call(undefined, ...args);
emit('change', ...args);
// 解决通过useTable注册onChange时不起作用的问题
const { onChange } = unref(getProps);
onChange && isFunction(onChange) && onChange.call(undefined, ...args);
}
const {
Expand Down
3 changes: 2 additions & 1 deletion src/views/demo/table/UseTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a-button class="mr-2" @click="clearSelect"> 清空选中行 </a-button>
<a-button class="mr-2" @click="getPagination"> 获取分页信息 </a-button>
</div>
<BasicTable @register="registerTable" @change="onChange" />
<BasicTable @register="registerTable" />
</div>
</template>
<script lang="ts">
Expand Down Expand Up @@ -54,6 +54,7 @@
columns: getBasicColumns(),
rowKey: 'id',
showTableSetting: true,
onChange,
rowSelection: {
type: 'checkbox',
},
Expand Down

0 comments on commit 9f5085c

Please sign in to comment.