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;
			},

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

相关推荐
码云之上7 小时前
WEB端小屏切换纯CSS实现
前端·css
Java编程爱好者7 小时前
JUnit 5 中的 @ClassTemplate 实战指南
javascript
sszdlbw7 小时前
后端springboot框架入门学习--第二篇
java·spring boot·学习
阿拉斯攀登7 小时前
MyBatis 全面解析 & Spring Boot 集成实战
java·spring boot·mybatis·持久层框架
A尘埃7 小时前
Java业务场景(高并发+高可用+分布式)
java·开发语言·分布式
白仑色7 小时前
java中的anyMatch和allMatch方法
java·linux·windows·anymatch·allmatch
刃神太酷啦7 小时前
C++ list 容器全解析:从构造到模拟实现的深度探索----《Hello C++ Wrold!》(16)--(C/C++)
java·c语言·c++·qt·算法·leetcode·list
wearegogog1237 小时前
C# 条码打印程序(一维码 + 二维码)
java·开发语言·c#
码农阿豪7 小时前
用 PlaylistDL 攒私人音乐库?加个 cpolar,出门在外也能随时听!
java