From ce5dd5fbb7cfcb819ff7074b24febe9dc44c91ff Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 2 Aug 2022 15:21:35 +0800 Subject: [PATCH] fix(gui-v2): replace by useVModel --- .../components/api-client/Headers.vue | 19 ++++++------------- .../components/api-client/Params.vue | 19 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui-v2/components/api-client/Headers.vue b/packages/nc-gui-v2/components/api-client/Headers.vue index 6111e18681..e465ffcdfc 100644 --- a/packages/nc-gui-v2/components/api-client/Headers.vue +++ b/packages/nc-gui-v2/components/api-client/Headers.vue @@ -6,18 +6,11 @@ interface Props { modelValue: Record[] } -const { modelValue } = defineProps() +const props = defineProps() -const emit = defineEmits(['update:modelValue']) +const emits = defineEmits(['update:modelValue']) -const localState = computed({ - get() { - return modelValue - }, - set(newValue: Record[]) { - emit('update:modelValue', newValue) - }, -}) +const vModel = useVModel(props, 'modelValue', emits) const headerList = ref([ 'A-IM', @@ -61,9 +54,9 @@ const headerList = ref([ 'X-CSRF-Token', ]) -const addHeaderRow = () => localState.value.push({}) +const addHeaderRow = () => vModel.value.push({}) -const deleteHeaderRow = (idx: number) => localState.value.splice(idx, 1) +const deleteHeaderRow = (idx: number) => vModel.value.splice(idx, 1)