Cannot read property ‘setRules‘ of undefined“found in,u-popup u-form 规则失效问题解决方案

html 复制代码
<template>
	<u-popup closeable border-radius="28" @close="close" mode="bottom" height="80%" v-model="show">

		<div class="wrapper">
			
			<div>
				<u-form :model="submitData" ref="uForm" label-position="left" :rules="ruleInline" :label-width="180">

						<u-input v-model="submitData.procureAccount"></u-input>
					</u-form-item>
				</u-form>

			</div>
		</div>
	</u-popup>
</template>

我们在methods 中写一个函数

javascript 复制代码
open() {
				this.show = true
				this.$nextTick(() => { //在弹窗加载出来只有 show 才会变成 true
					this.$refs.uForm.setRules(this.ruleInline);
				})
				
			},

然后在调用这个组件的时候,点击某个地方,通过ref得到就内部函数就可以了,

切记open()中show=true,要在最上面

javascript 复制代码
<invoices ref="invoices" :res="receiptList" @callbackInvoice="callbackInvoice" />
javascript 复制代码
// 判断发票
			invoice() {
				this.$refs.invoices.open()
				// this.invoiceFlag = true;
			},

本人实测没有问题,分享给大家,写的比较粗糙,还望海涵,有问题,评论区留言,有更好的方法,评论区可以评论一下,大家一起探讨,有用的话麻烦点个赞,谢谢各位同仁!!!

相关推荐
Rubin934 分钟前
判断元素在可视区域?用于滚动加载,数据埋点等
前端
爱学习的茄子4 分钟前
AI驱动的单词学习应用:从图片识别到语音合成的完整实现
前端·深度学习·react.js
用户3802258598245 分钟前
使用three.js实现3D地球
前端·three.js
程序无bug5 分钟前
手写Spring框架
java·后端
程序无bug7 分钟前
Spring 面向切面编程AOP 详细讲解
java·前端
zhanshuo7 分钟前
鸿蒙UI开发全解:JS与Java双引擎实战指南
前端·javascript·harmonyos
JohnYan7 分钟前
模板+数据的文档生成技术方案设计和实现
javascript·后端·架构
全干engineer19 分钟前
Spring Boot 实现主表+明细表 Excel 导出(EasyPOI 实战)
java·spring boot·后端·excel·easypoi·excel导出
Fireworkitte28 分钟前
Java 中导出包含多个 Sheet 的 Excel 文件
java·开发语言·excel
撰卢31 分钟前
如何提高网站加载速度速度
前端·javascript·css·html