摘要: 一、概述 需求:当点击确定按钮时隐藏下拉菜单。 主要使用的方法:ref 标识当前组件 van-dropdown-item ,当点击确定按钮时通过 getCurrentInstance 来获取组件身上的属性方法。 效果图: 二、实现方式 <template> <van-dropdown-menu> < 阅读全文
posted @ 2023-02-16 20:01 CodeFan* 阅读(1543) 评论(0) 推荐(0) 编辑
摘要: 一、概念 在 vue2 版本中,可以通过 this 来获取当前组件实例,但是在 vue3 setup 中是无法通过 this 获取组件实例对象,console.log(this) 打印出来的值是undefined。而使用 getCurrentInstance 方法就能获取当前组件的实例、上下文来操作 阅读全文
posted @ 2023-02-16 19:41 CodeFan* 阅读(1066) 评论(0) 推荐(0) 编辑