diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index d111780bd..eb387fe61 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -152,6 +152,10 @@ const value = computed({ }, }); +const computedSortBy = computed(() => { + return $props.sortBy || $props.optionLabel; +}); + watch(options, (newValue) => { setOptions(newValue); }); @@ -186,7 +190,7 @@ function findKeyInOptions() { } function setOptions(data) { - data = dataByOrder(data, $props.sortBy); + data = dataByOrder(data, computedSortBy.value); myOptions.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); emit('update:options', data);