7
禁止饿了么Element UI的Button 按钮组件的回车事件
source link: https://www.wikimoe.com/?post=243
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在Element UI里,如果点击过一次某个按钮,这个按钮就会被选择,然后这个时候按下回车就会连续触发按钮的点击事件,对一些需要服务器交互的按钮来说太过不友善。
根据官方文档,似乎禁不了这个事件,那么只能通过代码去禁止了。
- <el-button type="primary" ref="btn">按钮</el-button>
首先给按钮定义一个ref。
- mounted() {
- this.$refs.btn.$el.onkeydown= (e) =>{
- let _key=window.event.keyCode;
- if(_key===13){
- return false;
评论:
发表评论:
个人昵称
邮件地址 (选填)
个人主页 (选填)
OωO表情
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK