当前位置:网站首页>异常情况处置方案
异常情况处置方案
2022-07-30 14:20:00 【shewlong】
异常情况处置方案
文章目录
vue
ref
1.vscode报错 ‘show‘ does not exist on type ‘Vue | Element | Vue[] | Element[]‘. Property ‘show‘ do
this.$refs.modal.show
解决方法:将类型进行转换
(this.$refs.modal.show as any).show()
补充:
- ref
ref 被用来给元素或子组件注册引用信息。引用信息将会注册在父组件的 $refs 对象上。如果在普通的 DOM 元素上使用,引用指向的就是 DOM 元素;如果用在子组件上,引用就指向组件实例:
<!-- `vm.$refs.p` will be the DOM node -->
<p ref="p">hello</p>
<!-- `vm.$refs.child` will be the child component instance -->
<child-component ref="child"></child-component>
当 v-for 用于元素或组件的时候,引用信息将是包含 DOM 节点或组件实例的数组。
关于 ref 注册时间的重要说明:因为 ref 本身是作为渲染结果被创建的,在初始渲染的时候你不能访问它们 - 它们还不存在!$refs 也不是响应式的,因此你不应该试图用它在模板中做数据绑定。
- $ref
一个对象,持有注册过 ref attribute 的所有 DOM 元素和组件实例。
antD
form表单相关
1.Error in v-on handler: “TypeError: Cannot read property ‘resetFields‘ of undefined“
解决方法:对话是一个虚拟dom,visible!==true之前,dom未挂载在根节点上,此时refs的
原因:对话框表单未挂载到根节点上,导致无法识别resetFields方法
解决方法:
- resetfileds方法无法使用,让对话框完全开启后再使用resetfileds方法
this.visible = true;
(this.$refs.ruleForm as any).reserFields(); //ts语法,js可去掉类型转换
- ($nextTick dom下一次更新之后)
resetForm(formName) {
this.$nextTick(()=>{
this.$refs[formName].resetFields();
})
},
- (如果是第一次就点击新增就没必要reset, 根据元素undefined判断)
if (this.$refs[formName] !== undefined) {
this.$refs[formName].resetFields();
}
注意事项:对DOM一系列的js操作最好都要放进Vue.nextTick()的回调函数中
边栏推荐
- ECCV 2022 | 通往数据高效的Transformer目标检测器
- 网站添加能换装可互动的live 2d看板娘
- What is defect analysis?An article takes you to understand the necessary skills of test engineers
- 百家号取消接口发文功能:插外链获权重被堵死
- 这个编辑器居然号称快如闪电!
- 【Vue.js 3.0源码】KeepAlive 组件:如何让组件在内存中缓存和调度?
- sql中ddl和dml(sql与access的区别)
- 开始学习C语言了
- 00 testers of seasoning after nearly a year, whether to change careers or to learn the software testing students summarized the following heart advice
- Recommended open source tools: MegPeak, a high-performance computing tool
猜你喜欢

5G-based Warehousing Informatization Solution 2022

一文读懂网络效应对Web3的重要意义

CVE-2022-33891 Apache Spark 命令注入复现

华为再发「天才少年」召集令!曾放弃360万年薪的他也来首秀

Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review

canal scrape data

超T动力 盈运天下——中国重汽黄河/豪沃WP14T产品首发荣耀上市!

时间序列的数据分析(四):STL分解

Flink实时数仓完结

canal抓取数据
随机推荐
Recommended open source tools: MegPeak, a high-performance computing tool
Flask框架——Flask-Mail邮件
MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
MongoDB starts an error Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
LeetCode_98_验证二叉搜索树
MaxWell scraped data
71-page comprehensive overall solution for global tourism 2021 ppt
cookie模拟登录「建议收藏」
从实例来看DAO:权力分散的伟大尝试
基于FPGA的DDS任意波形输出
ECCV 2022 | 通往数据高效的Transformer目标检测器
BI-SQL丨WHILE
ESP32 Repeated Reboot Issue Arduino Shield Power Outage Detector
记面试外包公司的一次经历,到底该不该去?
产品年度营销计划书
Use of SLF4J
关于String的一些思考
What should I do if the sql server installation fails (what should I do if the sql server cannot be installed)
机器学习在竞赛和工业界应用区别
Before quitting, make yourself a roll king