perf: 【IoT 物联网】场景联动 nextTick 优化使用 await nextTick()

pull/808/head
puhui999 2025-08-07 17:49:20 +08:00
parent 5b38c9c394
commit f3d1989832
4 changed files with 21 additions and 30 deletions

View File

@ -237,10 +237,6 @@ const handleSubmit = async () => {
//
submitLoading.value = true
try {
// 使
console.log('提交数据:', formData.value)
// API
if (isEdit.value) {
//
await RuleSceneApi.updateRuleScene(formData.value)
@ -299,13 +295,12 @@ const initFormData = () => {
}
//
watch(drawerVisible, (visible) => {
watch(drawerVisible, async (visible) => {
if (visible) {
initFormData()
//
nextTick(() => {
formRef.value?.clearValidate()
})
await nextTick()
formRef.value?.clearValidate()
}
})

View File

@ -200,7 +200,7 @@ const handleTriggerTypeChange = (type: number) => {
}
//
const addSubGroup = () => {
const addSubGroup = async () => {
if (!trigger.value.conditionGroups) {
trigger.value.conditionGroups = []
}
@ -211,11 +211,10 @@ const addSubGroup = () => {
}
// 使 nextTick
nextTick(() => {
if (trigger.value.conditionGroups) {
trigger.value.conditionGroups.push([])
}
})
await nextTick()
if (trigger.value.conditionGroups) {
trigger.value.conditionGroups.push([])
}
}
const removeSubGroup = (index: number) => {

View File

@ -107,7 +107,7 @@ const subGroup = useVModel(props, 'modelValue', emit)
const maxConditions = computed(() => props.maxConditions || 3)
//
const addCondition = () => {
const addCondition = async () => {
// subGroup.value
if (!subGroup.value) {
subGroup.value = []
@ -128,11 +128,10 @@ const addCondition = () => {
}
// 使 nextTick
nextTick(() => {
if (subGroup.value) {
subGroup.value.push(newCondition)
}
})
await nextTick()
if (subGroup.value) {
subGroup.value.push(newCondition)
}
}
const removeCondition = (index: number) => {

View File

@ -462,25 +462,23 @@ const handleDataDisplay = (value: string) => {
//
watch(
() => localValue.value,
(newValue, oldValue) => {
async (newValue, oldValue) => {
//
if (newValue === oldValue) return
// 使 nextTick tick
nextTick(() => {
handleDataDisplay(newValue || '')
})
await nextTick()
handleDataDisplay(newValue || '')
},
{ immediate: true }
)
//
onMounted(() => {
nextTick(() => {
if (localValue.value) {
handleDataDisplay(localValue.value)
}
})
onMounted(async () => {
await nextTick()
if (localValue.value) {
handleDataDisplay(localValue.value)
}
})
//