vue3中$refs使用调整

前言: vue3环境

在vue2环境中,可以直接通过this.$refs获取模块;在vue3环境中,通用以下两种方式获取:

1、通过声明ref进行获取;

TypeScript 复制代码
import { ref} from 'vue';
const logoForm = ref();
console.log(logoForm.value);

2、通过声明getCurrentInstance进行获取;

TypeScript 复制代码
import { getCurrentInstance } from '@vue/runtime-core';
const currentInstance = getCurrentInstance();
console.log(currentInstance.ctx.$refs.logoForm);
相关推荐
恋猫de小郭4 小时前
AGENTS.md 真的对 AI Coding 有用吗?或许在此之前你没用对?
前端·人工智能·ai编程
sunny_6 小时前
构建工具的第三次革命:从 Rollup 到 Rust Bundler,我是如何设计 robuild 的
前端·rust·前端工程化
rfidunion7 小时前
springboot+VUE+部署(12。Nginx和前端配置遇到的问题)
前端·vue.js·spring boot
vx-Biye_Design7 小时前
servlet家政公司管理系统-计算机毕业设计源码01438
java·vue.js·spring·servlet·tomcat·maven·mybatis
珹洺7 小时前
Java-servlet(五)手把手教你利用Servlet配置HTML请求与相应
java·运维·服务器·前端·servlet·html·maven
FYKJ_20107 小时前
springboot大学校园论坛管理系统--附源码42669
java·javascript·spring boot·python·spark·django·php
QQ24391977 小时前
语言在线考试与学习交流网页平台信息管理系统源码-SpringBoot后端+Vue前端+MySQL【可直接运行】
前端·spring boot·sql·学习·java-ee
范特西.i8 小时前
QT聊天项目(6)
前端
a1117768 小时前
水体渲染系统(html开源)
前端·开源·threejs·水体渲染
程序员小李白8 小时前
CSS 盒子模型
前端·css·html