1.打开新窗口的内嵌
<div class="easy-content-sroll">
<div class="easy-index-img"><img src="//www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" alt=""></div>
<div class="easy-index-title">
<el-input type="text" v-model="inputVal" :class="calssName" @click.native="clickHistory($event)" @keyup.enter.native="inputEnter($event)" name="wd" clearable></el-input>
<input class="easy-index-btn" type="submit" value="百度一下" @click="butClick"/>
<!-- 搜索记录 -->
<div class="easy-div-search" v-show="expanded" >
<ul>
<li @click="liClick(v.id)" :id="v.id" v-for="v in historyList" :key="v.id">{{v.title}}</li>
</ul>
</div>
</div>
</div>
export default {
methods: {
inputEnter() {
var open_url = "https://www.baidu.com/s?ie=utf-8&wd=" + this.inputVal;
window.open(open_url);
this.historyFn();
},
historyFn() {
if(this.inputVal) {
this.historyList = JSON.parse(sessionStorage.getItem('historyList')) || [];
const obj = {
id: 'dom' + Math.random()*100,
title: this.inputVal
}
this.historyList.unshift(obj)
sessionStorage.setItem('historyList',JSON.stringify(this.historyList.splice(0,8)));
}
},
// 百度
clickHistory(ev) {
ev.cancelBubble=true; /*阻止冒泡*/
this.historyList = JSON.parse(sessionStorage.getItem('historyList')) || [];
if(this.historyList.length) {
this.expanded = true;
this.calssName = "easy-input-record";
} else {
this.calssName = "";
}
},
};
2 不开新窗口的内嵌
<div class="box-img"><img src="//www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" alt=""></div>
<div class="box-title">
<form action="https://www.baidu.com/s" >
<input type="text" class="text-input" name="wd"/><input class="btn-input" type="submit" value="百度一下"/>
</form>
</div>