调取手机软键盘的搜索功能

点击软键盘的搜索按钮往往第一次页面会刷新一次,只有点击第二次才会出现想要的效果,所以将from的target对应到iframe,就不会刷新了

很多时候点击搜索以后会出现比较长的列表,软键盘会盖住用户搜索的信息,我们点击一下屏幕才会使软键盘消失,这样用户体验也不是很好,所以我们可以在调用的方法中加一个软键盘收起的方法
HTML部分

<template>
    <form target="frameFile" id="search_from"> 
        <input id="suggestId" v-model="mmaddress" type="search" placeholder="搜索地点"/>
        <iframe name='frameFile' style="display: none;"></iframe>
    </form>
</template>

JS部分

mounted() {
    let _this = this;
    document.getElementById('search_from').onsubmit = function(e){
        _this.search(e);
        document.activeElement.blur();//软键盘收起
    }
}

本文参照自-大牛博主

猜你喜欢

转载自blog.csdn.net/call_me_small_pure/article/details/79914943
今日推荐