vue 点击一个div,使input获得焦点

<div class="inputMessage" @click="inputMessage">输入留言</div>
<input type="text" v-model="textMessage" class="textMeassge" ref="child">

inputMessage:function() {
 let childMessage = this.$refs.child
 setTimeout(function () { //因为vue页面使用jquery在DOM未渲染完成之前事件绑定不上,所有需要延时(jquery不适合在vue页面中使用,但查了好多资料,没找到合适的vux获取input焦点的代码,就果断选择了这个)
   childMessage.focus()
 }, 500)
}
原文地址:https://www.cnblogs.com/gqx-html/p/7602232.html