mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-16 18:09:22 +08:00
feat(form): select动态监听事件优化
This commit is contained in:
parent
7020ab4a1f
commit
040d5d0d2c
@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref, watch } from 'vue';
|
import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
|
import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
|
||||||
import { getConfig } from '../utils/config';
|
import { getConfig } from '../utils/config';
|
||||||
@ -264,9 +264,7 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof props.config.options === 'function') {
|
if (typeof props.config.options === 'function') {
|
||||||
watch(
|
watchEffect(() => {
|
||||||
() => mForm?.values,
|
|
||||||
() => {
|
|
||||||
typeof props.config.options === 'function' &&
|
typeof props.config.options === 'function' &&
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
props.config.options(mForm, {
|
props.config.options(mForm, {
|
||||||
@ -279,20 +277,11 @@ export default defineComponent({
|
|||||||
).then((data) => {
|
).then((data) => {
|
||||||
options.value = data;
|
options.value = data;
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
{
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else if (Array.isArray(props.config.options)) {
|
} else if (Array.isArray(props.config.options)) {
|
||||||
watch(
|
watchEffect(() => {
|
||||||
() => props.config.options,
|
|
||||||
() => {
|
|
||||||
options.value = props.config.options as SelectOption[] | SelectGroupOption[];
|
options.value = props.config.options as SelectOption[] | SelectGroupOption[];
|
||||||
},
|
});
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
} else if (props.config.option) {
|
} else if (props.config.option) {
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
if (!props.model) return;
|
if (!props.model) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user