//模板中给组件指定ref
<div>
<input ref="user_name" />
</div>
let input = this.$refs.user_name;
input.focus();
或者
let input= this.$refs["user_name"];
input[0].focus();
//相同写法
this.$refs["user_name"][0].focus(); //
07-12
888
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-10
3673
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-06