<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script>
<style>
img{max-width:125px;}
</style>
</head>
<body>
<div id="app">
<input type="text" value="tttttttttttttttttt" @keyup.enter="a">
<button @click="b">测试</button>
</div>
<script>
new Vue({
el:"#app",
methods:{
a:function(){
alert(1);
},
b:function(){
alert(2);
}
}
});
</script>
</body>
</html>
输入框中按回车键
1.谷歌上弹1
2.ie浏览器弹2
:很明显ie10上,input的@keyup绑定无效,而且焦点自动转移到button上去了。
有人能解释下这个缘由吗
你试试申明type为
button
能解决。是ie问题。https://fiddle.jshell.net/oee...
补充知识点:
<button>和<input type="button"> 的区别
http://www.cnblogs.com/puredi...