feat(table): 新增 changeSelectedKeys 回调
This commit is contained in:
parent
a1824b2da4
commit
e1c8e1f7c6
@ -127,7 +127,7 @@ export default {
|
||||
|
||||
<template>
|
||||
{{selectedKeys}}
|
||||
<lay-table :columns="columns" id="id" :dataSource="dataSource" default-toolbar="true" :selectedKeys="selectedKeys" checkbox="true">
|
||||
<lay-table :columns="columns" id="id" :dataSource="dataSource" default-toolbar="true" :selectedKeys="selectedKeys" @changeSelectedKeys="changeSelectedKeys" checkbox="true">
|
||||
<template v-slot:toolbar>
|
||||
<lay-button>新增</lay-button>
|
||||
<lay-button>删除</lay-button>
|
||||
@ -149,6 +149,10 @@ export default {
|
||||
|
||||
const selectedKeys = ref(['1'])
|
||||
|
||||
const changeSelectedKeys = function(val) {
|
||||
selectedKeys.value = val
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title:"账户",
|
||||
@ -181,6 +185,7 @@ export default {
|
||||
columns,
|
||||
dataSource,
|
||||
selectedKeys,
|
||||
changeSelectedKeys
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup name="LayTable" lang="ts">
|
||||
import { defineProps, ref, useSlots, watch, withDefaults, defineEmits } from 'vue'
|
||||
import { defineProps, ref, useSlots, watch, withDefaults, defineEmits, computed } from 'vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@ -124,9 +124,13 @@ const props = withDefaults(
|
||||
}
|
||||
)
|
||||
|
||||
const tableSelectedKeys = ref(props.selectedKeys)
|
||||
const tableSelectedKeys = ref([...props.selectedKeys])
|
||||
|
||||
const emit = defineEmits(['change'])
|
||||
watch(tableSelectedKeys, function(val){
|
||||
emit('changeSelectedKeys',val)
|
||||
},{deep: true})
|
||||
|
||||
const emit = defineEmits(['change','changeSelectedKeys'])
|
||||
|
||||
const slot = useSlots()
|
||||
const slots = slot.default && slot.default()
|
||||
|
Loading…
Reference in New Issue
Block a user