// 搜索事件
custom(value) {
if (!value) {
// this.$common.errorToShow 是封装的提示框方法
this.$common.errorToShow('请输入关键词搜索');
return;
}
// this.$db.get 是封装的获取异步缓存方法
if (this.$db.get(‘key’)) {
this.keyMap = this.$db.get('key');
}
// this.keyMap 是数组 []
let offset = this.keyMap.indexOf(value);
if (offset >= 0) {
// 判断 this.keyMap 数组中是否已存在,存在则剔除splice
this.keyMap.splice(offset, 1);
}
// 追加到数组中
this.keyMap.push(value);
this.$db.set(‘key’, this.keyMap);
}
},
uniapp搜索之历史记录
最新推荐文章于 2024-06-12 14:27:12 发布