<uni-forms ref="valiForm">
</uni-forms> - 发布:2025-12-09 20:35
- 更新:2025-12-09 21:00
- 阅读:22
产品分类: uniapp/小程序/钉钉
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 4.85
第三方开发者工具版本号: 4.85
基础库版本号: vue3,uni-ui 1.5.11
项目创建方式: HBuilderX
示例代码:
操作步骤:
随便个页面添加
<uni-forms ref="valiForm">
</uni-forms>
随便个页面添加
<uni-forms ref="valiForm">
</uni-forms> 预期结果:
能加 ref
能加 ref
实际结果:
TypeError: Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'valiForm is not defined'''''
at Object.returnValue ((index):1441:13)
at processReturnValue ((index):862:29)
at (index):808:27
at c.emit (af-appx.worker.min.js:26:64929)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
at i (af-appx.worker.min.js:26:63855)
at c.emit (af-appx.worker.min.js:26:64954)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
TypeError: Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'valiForm is not defined'''''
at Object.returnValue ((index):1441:13)
at processReturnValue ((index):862:29)
at (index):808:27
at c.emit (af-appx.worker.min.js:26:64929)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
at i (af-appx.worker.min.js:26:63855)
at c.emit (af-appx.worker.min.js:26:64954)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
bug描述:
<uni-forms ref="valiForm">
</uni-forms>
加上ref="valiForm"报错:ReferenceError: valiForm is not defined 然后,就慢慢的卡死,TypeError 信息越来越多知道卡死。
TypeError: Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'Cannot create property 'errMsg' on string 'valiForm is not defined'''''
at Object.returnValue ((index):1441:13)
at processReturnValue ((index):862:29)
at (index):808:27
at c.emit (af-appx.worker.min.js:26:64929)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
at i (af-appx.worker.min.js:26:63855)
at c.emit (af-appx.worker.min.js:26:64954)
at Jv.onerror (af-appx.worker.min.js:26:407007)
at n (144b417e-de6c-4958-8711-25d189d13c67:1:95)
注:去掉 ref="valiForm" 就没问题。
vue3
3 个回复
Ask小助手
该bug反馈内容基本完整但存在关键缺失:标题和描述清晰,但代码示例过于简略(缺少完整页面结构和script部分),复现步骤模糊(未说明页面类型是vue/nvue),且未提供uni-app核心版本号(仅HBuilderX 4.85)。实际结果中的TypeError堆栈显示错误处理系统异常,但"valiForm is not defined"不符合Vue规范——ref属性本身不会触发ReferenceError,正常应通过this.$refs.valiForm访问。
经核查知识库uni-forms文档,组件明确支持ref用于调用setRules/validate等方法,且文档示例包含ref用法。该问题可能由以下原因导致:
建议用户:
此反馈疑似环境配置或使用方式问题,非组件设计缺陷,但需更多现场信息确认。
2***@qq.com (作者) - 嗯嗯嗯,撂了吧,我写bug呢。
不用代码多了,在组件里这样就报错
2***@qq.com (作者) - 嗯嗯嗯,撂了吧,我写bug呢。
我擦,真服了,在下面定义了 ref 就好了
要回复问题请先登录或注册
公告
更多>相关问题