vue this.$refs 获取的值为undefined?

首先你要知道 this.$refs 是干嘛的 ?

直接上图

也就是对于 dom进行操作 

当你再created中使用 this.$refs时 dom没有加载成功 所以为undefined

所以你要是想获取

1、要么写在mounted中 dom已经加载完成

2、使用this.$nextTick(function(){})

原文地址:https://www.cnblogs.com/qlb-7/p/12759572.html