vue Antd 输入框Input自动聚焦
1、从vue的实例属性$ref去调input的focus方法使其实现聚焦。<a-input type="text ref="ainput" /><button @click="handleChange"></button>2、点击button自动聚焦,或其他事件需要聚焦methods:{handleChange(){this.$nextTick(()=>{
·
1、从vue的实例属性$ref去调input的focus方法使其实现聚焦。
<a-input type="text ref="ainput" />
<button @click="handleChange"></button>
2、点击button自动聚焦,或其他事件需要聚焦
methods:{
handleChange(){
this.$nextTick(()=>{
this.$refs.ainput.focus()
})
}
}
更多推荐
已为社区贡献3条内容
所有评论(0)