We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.发生了什么 instance.value?.ctx.$children 始终存在销毁节点,导致其length不断增多 ex:
<NhForm> <NhField></NhField> <NhField></NhField> <NhField v-if=“条件判断”></NhField> </NhForm>
<script setup lang="ts"> defineOptions({ name: "NhForm", }); const instance = ref(null); onMounted(() => { instance.value = getCurrentInstance(); }); const nhFormRef = ref(null); // const nhFormInstance = getCurrentInstance(); const validate = () => { return new Promise((resolve, reject) => { console.log(instance.value?.ctx.$parent.$children.length, 'nhFormRef') if (!!instance.value?.ctx.$children.length) { const hasInValid = instance.value?.ctx.$children.filter((item: any) => !item.validate()); resolve(!hasInValid.length); } else { resolve(true); } }); }; defineExpose({ validate, }); </script> <template> <form class="nh-form" id="id"> <template> <slot /> </template> </form> </template>
通过 instance.value?.ctx.$children 获取 当前 slot 插槽渲染的组件,如果渲染组件时,内有条件组件,会导致这个 children.length 不断增加,比如当前实际3个节点,内部因条件事件导致出现了5个节点,销毁的节点也在。
期望: instance.value?.ctx.$children 移除销毁节点;
{ endMeasure(instance, `init`); } { if (options.parentComponent && instance.proxy) { // 具体源码问题出现在这里, 只有push,没有移除操作。 options.parentComponent.ctx.$children.push(getExposeProxy(instance) || instance.proxy); } } setupRenderEffect(instance); { popWarningContext(); endMeasure(instance, `mount`); }
The text was updated successfully, but these errors were encountered:
已确认bug,下个版本修复。 非常不推荐使用$children api, 这个api 在vue3语法内是没有的,是uniapp内部特殊添加的。你这个需求应该可以通过 provide,inject api来解决
Sorry, something went wrong.
fix(mp): 自定义组件卸载时从父组件的$children中移除 (#5143)
4a72f42
好的,后面我再改造一下,非常感谢
No branches or pull requests
1.发生了什么
instance.value?.ctx.$children 始终存在销毁节点,导致其length不断增多
ex:
通过 instance.value?.ctx.$children 获取 当前 slot 插槽渲染的组件,如果渲染组件时,内有条件组件,会导致这个 children.length 不断增加,比如当前实际3个节点,内部因条件事件导致出现了5个节点,销毁的节点也在。
期望:
instance.value?.ctx.$children 移除销毁节点;
The text was updated successfully, but these errors were encountered: