提交 9f5085c9 作者: 无木

fix(table): useTable support onChange

修复useTable无法直接通过设置onChange来注册change事件响应的问题
上级 9f4d1719
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
import { omit } from 'lodash-es'; import { omit } from 'lodash-es';
import { basicProps } from './props'; import { basicProps } from './props';
import { isFunction } from '/@/utils/is';
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -142,6 +143,9 @@ ...@@ -142,6 +143,9 @@
function handleTableChange(...args) { function handleTableChange(...args) {
onTableChange.call(undefined, ...args); onTableChange.call(undefined, ...args);
emit('change', ...args); emit('change', ...args);
// 解决通过useTable注册onChange时不起作用的问题
const { onChange } = unref(getProps);
onChange && isFunction(onChange) && onChange.call(undefined, ...args);
} }
const { const {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<a-button class="mr-2" @click="clearSelect"> 清空选中行 </a-button> <a-button class="mr-2" @click="clearSelect"> 清空选中行 </a-button>
<a-button class="mr-2" @click="getPagination"> 获取分页信息 </a-button> <a-button class="mr-2" @click="getPagination"> 获取分页信息 </a-button>
</div> </div>
<BasicTable @register="registerTable" @change="onChange" /> <BasicTable @register="registerTable" />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
columns: getBasicColumns(), columns: getBasicColumns(),
rowKey: 'id', rowKey: 'id',
showTableSetting: true, showTableSetting: true,
onChange,
rowSelection: { rowSelection: {
type: 'checkbox', type: 'checkbox',
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论