Browse Source

fix(table): useTable support onChange

修复useTable无法直接通过设置onChange来注册change事件响应的问题
pull/678/head
无木 5 years ago
parent
commit
9f5085c9f9
  1. 4
      src/components/Table/src/BasicTable.vue
  2. 3
      src/views/demo/table/UseTable.vue

4
src/components/Table/src/BasicTable.vue

@ -58,6 +58,7 @@
import { omit } from 'lodash-es';
import { basicProps } from './props';
import { isFunction } from '/@/utils/is';
export default defineComponent({
components: {
@ -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 {

3
src/views/demo/table/UseTable.vue

@ -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">
@ -54,6 +54,7 @@
columns: getBasicColumns(),
rowKey: 'id',
showTableSetting: true,
onChange,
rowSelection: {
type: 'checkbox',
},

Loading…
Cancel
Save