feat: base xtSelect支持延迟加载

This commit is contained in:
TianyangZhang 2025-11-06 11:07:24 +08:00
parent a40dd9079a
commit 0febf3f507
1 changed files with 20 additions and 3 deletions

View File

@ -69,7 +69,7 @@
</template> </template>
<script setup> <script setup>
import { ref, defineProps, defineEmits, computed, onMounted } from "vue"; import { ref, defineProps, defineEmits, computed, onMounted, watch } from "vue";
const props = defineProps({ const props = defineProps({
multiple: { type: Boolean, default: false }, multiple: { type: Boolean, default: false },
@ -103,8 +103,25 @@ onMounted(() => {
tableData.value = props.options; tableData.value = props.options;
hidePagination.value = true; hidePagination.value = true;
} }
watch(
() => props.label,
async (newVal) => {
init()
},
{ deep: true, immediate: true }
);
watch(
() => props.modelValue,
async (newVal) => {
init()
},
{ deep: true, immediate: true }
)
if (props.label) { });
const init = () => {
if (props.label) {
selectLabel.value = props.label; selectLabel.value = props.label;
} else { } else {
if (props.multiple) { if (props.multiple) {
@ -133,7 +150,7 @@ onMounted(() => {
} }
} }
} }
}); }
const isFixOptions = ref(false); const isFixOptions = ref(false);
const tableData = ref(null); const tableData = ref(null);