fix: 产物更新 v1.3.1,修复编辑弹窗「点确定没反应」
对应源码仓库 commit 0692249。UmTableForm 的表单 vnode 改由 render() 创建 (删除 computed.formCom,新增 methods.buildForm),避免 Vue 3.5 在渲染外重算 computed 导致字符串 ref 失去 owner、$refs.formRef 为 null;并新增 getFormInstance() 兜底回捞 ElForm 实例。 消费方实测:旧产物点确定无反应,新产物弹窗正常关闭并提交成功。
This commit is contained in:
Vendored
+20
-5
@@ -4,6 +4,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
[x: string]: any;
|
||||
}>;
|
||||
setFormModel: (models: any) => void;
|
||||
getFormInstance: () => any;
|
||||
}, {
|
||||
rules: Record<string, any>;
|
||||
formItems: any[];
|
||||
@@ -16,11 +17,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
cascadeMap: Map<string, string[]>;
|
||||
/** 表单刷新按 100ms 合并,避免连续输入时反复重建整个表单 */
|
||||
throttleRefreshForm: import("lodash").DebouncedFunc<(this: any, v: any, oldV: any, needFreshCascadeField: string[]) => Promise<void>>;
|
||||
}, {
|
||||
formCom(): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | null;
|
||||
}, {
|
||||
}, {}, {
|
||||
refreshForm(v: any, oldV: any, needFreshCascadeField: string[]): Promise<void | undefined>;
|
||||
onSubmit(): Promise<void>;
|
||||
/** 把 `IFormRule` 翻译成 element-plus 的 FormItemRule */
|
||||
@@ -91,6 +88,24 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
init(): Promise<void>;
|
||||
/** 单字段赋值:整体替换对象,触发父层的 formModel watch */
|
||||
initForm(fieldName: string, value: any): void;
|
||||
/**
|
||||
* 造出 ElForm 的 vnode。
|
||||
*
|
||||
* ⚠️ 必须由 `render()` 直接调用,**不要**挪回 `computed` 里。
|
||||
*
|
||||
* Vue 3.5 起,调度器会在渲染之外重新求值 computed
|
||||
* (`flushJobs` → `runIfDirty` → `refreshComputed`,实测在首次渲染后 2ms 就会来一次)。
|
||||
* 那一刻 `currentRenderingInstance` 是 null,于是 `h(ElForm, { ref: "formRef" })`
|
||||
* 造出来的 vnode 里 ref 的 owner 就是 null;Vue 的 `setRef` 会打印
|
||||
* `Missing ref owner context. ref cannot be used on hoisted vnodes`
|
||||
* 并**直接跳过赋值** —— `$refs.formRef` 永远是 null。
|
||||
*
|
||||
* 症状极具迷惑性:表单照常渲染、数据照常回填,只有「点确定」没反应
|
||||
* (`onSubmit` 里 `refs.formRef?.validate?.()` 静默落空),
|
||||
* 而且是否复现取决于「最后一次求值落在渲染内还是渲染外」。
|
||||
* 在 render 里创建则每次都有正确的 owner。
|
||||
*/
|
||||
buildForm(): any;
|
||||
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("ok" | "cancel" | "formModelChange")[], "ok" | "cancel" | "formModelChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
||||
onOk?: ((...args: any[]) => any) | undefined;
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
|
||||
Reference in New Issue
Block a user