页面一加载就会让文本框获得焦点
当光标失去焦点后,文本框又会自动获得焦点
光标点击之后,仍然可以进行跳转
document.getElementById("input1").focus(); //获取焦点
<template> <div> <el-input v-model="input" @blur="shiquinput" id="input1" placeholder="请输入内容" class="input-form"></el-input> <el-input placeholder="请输入内容" class="input-form"></el-input> <el-input placeholder="请输入内容" class="input-form"></el-input> </div> </template>
<script> export default { data() { return { input: "" }; }, mounted() { document.getElementById("input1").focus(); //获取焦点 }, methods: { shiquinput() { console.log("chufale "); this.input = ""; document.getElementById("input1").focus(); //失去焦点后又获取焦点 } } }; </script> <style lang="scss" scoped> .input-form { width: 300px; margin-top: 20px; margin-left: 20px; }