HTML
<view class="form-item-input" v-if="item.type=='text'">
<input name="input"
autocomplete="on"
:placeholder="item.des ? item.des:'请输入'"
v-model="item.value"
@focus="showHistory(item)"
@input="findHistory"
/>
<!--历史记录!-->
<view v-if="selectFilter.widgetName == item.widgetName" class="history" style="width: 100%;position: absolute;background: #FFF;border: 2rpx solid #ccc; z-index: 999;border-top: none;">
<view
v-for="(history,index) in searchList"
:key="index"
v-if="item.widgetName == history.widgetName"
@tap="historySearch(history)"
style="padding: 5rpx 20rpx"
>
{
{ history.value }}
</view>
</view>
searchMsg(option) {
// 存入缓存
console.log(option)
if(option != ''){
try {
let value = uni.getStorageSync(this.contestId)
if(value){
// 最多缓存20条记录
this.searchList = JSON.parse(value).slice(0,20)
}
//去重
let index = this.searchList.indexOf(option)
if(index > -1){
this.searchList.splice(index,1)
}
this.searchList.slice(0,this.searchList.length)
this.searchList = option
uni.setStorageSync(this.contestId, JSON.stringify(this.searchList))
}catch(e){
console.log(e)
}
// 清空searchList
this.clearList()
}
},