useAttrs
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-12 14:13:35 +02:00
parent b30da92c1d
commit bfab1ec314
1 changed files with 5 additions and 10 deletions

View File

@ -1,7 +1,6 @@
<script setup>
import { ref, onBeforeMount } from 'vue';
import { ref, onBeforeMount, useAttrs } from 'vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import { useArrayData } from 'src/composables/useArrayData';
const $props = defineProps({
row: {
@ -12,19 +11,15 @@ const $props = defineProps({
type: String,
default: null,
},
url: {
type: String,
default: '',
},
});
const options = ref([]);
onBeforeMount(async () => {
const findBy =
$props.find ?? $props.url.charAt(0).toLocaleLowerCase() + $props.url.slice(1, -1);
options.value = [$props.row[findBy]];
const { url } = useAttrs();
const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
if (findBy) options.value = [$props.row[findBy]];
});
</script>
<template>
<VnSelect v-bind="$attrs" :options="$attrs.options ?? options" :url="url" />
<VnSelect v-bind="$attrs" :options="$attrs.options ?? options" />
</template>