通过点击button或回车键将数据存储到本地的localStorage中

本人搭建的是搜索框功能
前端
html

<div class="SearchBox">
                    <form id="SearchBox" action="SearchBox">
                       <div id="SearchBoxClassification" style=""> 
                           <ul id="SearchBoxClassification_Box">
                              <li class="SearchBoxClassification_ba" id="SearchClassification_ba">宝贝</li>
                              <li class="SearchBoxClassification_ba" id="SearchClassification_bb">天猫</li>
                              <li class="SearchBoxClassification_ba" id="SearchClassification_bc">店铺</li>
                           </ul>
                           <div class="SearchTriangleMarrk">
                               <span class="SearchTriangleMark_icon">
                                    <span class="SearchTriangleMark_icon_ba"><img src="image/downarrow.png" alt="inverted" width="12px" height="12px" /></span>
                               </span>
                           </div>
                        </div>
                        <i class="SearchBoxBoundary"></i>
                        <div id="SearchTextBoxBody">
                            <input type="text" v-model="showHistory" id="SearchInputBox" h-model="showHistory"  autocomplete="off">
                            <div id="SearcheMagnifierbody" style="">
                               <i class="SearchMagnifier"></i>
                               <span id="SearchMagnifierText">男装</span>    
                            </div>
                        </div>
                        <div id="SearchButtonBody">
                           <button id="SearchButton_ba" type="submit">搜索</button>
                        </div>
                     </form>
                 </div>
                 <div class="SoftwareDownloadQRCode">
                    <a href="" class="SoftwareQRcode_ba">
                       <span class="SoftwareQRcodeText">软件下载</span>
                       <i class="SoftwareQRcode_icon"><img src="image/Qr_code.png" alt="QRcode" width="67px" height="67px"></i>    
                     </a>
                 </div>
             </div>

js

//搭建model
function showHistory (showHistory){
    this.name = showHistory;
}
showHistory.prototype.saveTolStorage = function(){
    //将this写入本地存储
    //先将以前的数据取出来,然后在合并到数据中,在写回去
    var storage = window.localStorage.getItem('showHistory');
    storage = storage ? JSON.parse(storage) : [];
    storage.push(this);
    window.localStorage.setItem('showHistory',JSON.stringify(storage));
}
showHistory.selectByName = function(showHitory){
    var storage = window.localStorage.getItem(showHitory);
    storage = storage ? JSON.parse(storage) : [];
    return storage.some(function (v){
        return v.name === showHitory;
    });
}

请帮助一下谢谢,

不知道是否是要回车的效果跟点击了登录的效果一样
如果是的话,你可以通过给input标签绑定@keydown="enterToLogin"事件
然后enterToLogin写逻辑

enterToLogin (ev) {
        ev.keyCode === 13 && this.login()
    }