element ui 中添加回车事件,input失去焦点
2022-10-08 17:22:18
233
{{single.collect_count}}

vue项目中使用了element ui,使用回车事件时加.native,写法如下:

<el-input @keyup.enter.native="handleEnter($event)" v-model="scope.row.name" :value="scope.row.name" />
 // 回车失去焦点 handleEnter(event){event.target.blur();// 回车失去焦点单独写 // 更新操作应该放到失去焦点的事件中,后面调用接口时重新写blur方法this.$message.success('修改成功');},

还可以直接写到页面中,将回车事件指向失去焦点,相关操作放在handleBlur方法中

<el-input v-model="scope.row.name" :value="scope.row.name"@keyup.enter.native="$event.target.blur" @blur="handleBlur"/>
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}