useAttrs
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
b30da92c1d
commit
bfab1ec314
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onBeforeMount } from 'vue';
|
import { ref, onBeforeMount, useAttrs } from 'vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
row: {
|
row: {
|
||||||
|
@ -12,19 +11,15 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const options = ref([]);
|
const options = ref([]);
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
const findBy =
|
const { url } = useAttrs();
|
||||||
$props.find ?? $props.url.charAt(0).toLocaleLowerCase() + $props.url.slice(1, -1);
|
const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
|
||||||
options.value = [$props.row[findBy]];
|
if (findBy) options.value = [$props.row[findBy]];
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSelect v-bind="$attrs" :options="$attrs.options ?? options" :url="url" />
|
<VnSelect v-bind="$attrs" :options="$attrs.options ?? options" />
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue