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

直接上图

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

 

 

也就是对于 dom进行操作 

 

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

所以你要是想获取

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

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

 

 

相关文章:

  • 2023-01-23
  • 2021-08-01
  • 2023-03-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-03
  • 2021-10-10
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案