1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > vue element.ui中input框自动获取焦点

vue element.ui中input框自动获取焦点

时间:2023-10-18 08:47:52

相关推荐

vue element.ui中input框自动获取焦点

vue element.ui中input框自动获取焦点

需求:element-ui中使el-input标签自动获取焦点

解决方法

HTML:

// 使用自定义指令 v-focus<el-input v-focus size="small" v-model="ment" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)" ></el-input>

JS:

// 使用directives注册v-focus全局指令directives: {focus: {inserted: function (el) {el.querySelector('input').focus()}}},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。