fori,
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<div id="vue">
<button @click="foc">show+focus</button>
<input type="text" id="ob" v-show="show" ref="test">
</div>
<script>
var vue = new Vue({
el: '#vue',
data: {
show:false,
},
methods: {
foc(){
(vue.show=!vue.show) && this.$nextTick(() => this.setFocus());
},
setFocus() {
this.$refs.test.focus();
}
}
})
</script>