|
|
@@ -1,9 +1,9 @@ |
|
|
|
<template> |
|
|
|
<n-switch v-bind="getSwitchProps" v-model:value="switchVlue" @update:value="changeValue" /> |
|
|
|
<n-switch v-bind="getSwitchProps" v-model:value="getSwitchValue" @update:value="changeValue" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { defineComponent, ref, unref, computed } from 'vue' |
|
|
|
import { defineComponent, unref, computed } from 'vue' |
|
|
|
export default defineComponent({ |
|
|
|
name: 'TableSwitch', |
|
|
|
props: { |
|
|
@@ -18,10 +18,16 @@ export default defineComponent({ |
|
|
|
}, |
|
|
|
emits: ['change'], |
|
|
|
setup(props, { emit }) { |
|
|
|
const switchVlue = ref() |
|
|
|
const { data, rowKey } = unref(props) |
|
|
|
switchVlue.value = rowKey ? data[rowKey] : data |
|
|
|
// const switchValue = ref() |
|
|
|
// const { data, rowKey } = unref(props) |
|
|
|
// switchValue.value = rowKey ? data[rowKey] : data |
|
|
|
const getSwitchValue = computed(() => { |
|
|
|
const { data, rowKey } = unref(props) |
|
|
|
const value = rowKey ? data[rowKey] : data |
|
|
|
return value |
|
|
|
}) |
|
|
|
const getSwitchProps = computed(() => { |
|
|
|
console.log(111) |
|
|
|
return { |
|
|
|
...unref(props) |
|
|
|
} |
|
|
@@ -35,7 +41,8 @@ export default defineComponent({ |
|
|
|
emit('change', params) |
|
|
|
} |
|
|
|
return { |
|
|
|
switchVlue, |
|
|
|
// switchValue, |
|
|
|
getSwitchValue, |
|
|
|
getSwitchProps, |
|
|
|
changeValue |
|
|
|
} |