一、图片预览
import { ImagePreview } from "vant";
setTimeout(() => {
this.previewImg();
}, 100);
previewImg() {
let contentEl = this.$refs.contentRef;
let imgs = contentEl.querySelectorAll("img");
let images=[]
imgs.forEach((element,index) => {
images.push(element.src)
element.onclick=function(){
ImagePreview({
images,
startPosition:index
})
}
});
},
二、去重
onSearch(val) {
if(!this.searchText){
return
}
this.searchText = val;
// 方法一
// let index=this.searchHistories.indexOf(val)
// if(index>=0){
// this.searchHistories.splice(index,1)
// }
// this.searchHistories.unshift(val)
// 方法二
// this.searchHistories.unshift(val)
// this.searchHistories=[...new Set(this.searchHistories)]
// 方法三
this.searchHistories.unshift(val)
this.searchHistories=_.uniq(this.searchHistories)
this.isResult = true;
//console.log(this.isResult);
},
onCancel() {
this.$router.back();
},