// 搜索事件
		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);
			}
		},

更多推荐