监听input框enter事件

Html 发表时间:2019-12-20 18:35:39 作者:梁子亮 浏览次数:1431

html布局

<input class="searchInput" @keypress="fnToEnter" v-model="searchVal" placeholder="" type="text" />

js代码

fnToEnter(e){
    if(e.keyCode == 13 || e.which == 13){
        location.href = './search.html?keyword=' + this.searchVal;
    }
},