vue input自动获取焦点 逃离我推掉我的手 2022-03-16 14:54 330阅读 0赞 **方法一 这个方法适合vue插件,id比较好绑定** // html 部分 <input type="text" id="name"> // js部分 mounted() { this.$nextTick(() =>{ document.getElementById('phone').focus(); }) }, **方法二 这个如果插件解决不了ref的绑定还是用ID吧** //html 部分 <input type="text" ref="name"> // js 部分 mounted() { this.$nextTick(() =>{ this.$refs.name.focus() }) },
还没有评论,来说两句吧...