Vue实现文本框自动获取焦点
<template>
<div>
<!-- 文本框 -->
<input type="text" v-focus/>
</div>
</template>
<script>
export default {
name: "",
data() {
return {
};
},
mounted() {
},
methods: {
},
computed: {
},
watch: {
},
//自定义指令
directives: {
// 该focus 在input框中用v-focus调用
focus: {
inserted: function (el) {
el.focus();
},
},
},
};
</script>