Răsfoiți Sursa

优化搜索历史

gcz 2 ani în urmă
părinte
comite
1c213ddeaa
2 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 5 1
      shopping/productsearch.vue
  2. 2 1
      shopping/searchhistory.vue

+ 5 - 1
shopping/productsearch.vue

@@ -160,7 +160,11 @@
 				
 				// 存储历史数据
 				let index = this.searchHistory.findIndex(item => item.name === that.params.goodsName);
-				console.log('index',index);
+				// console.log('index',index);
+				const name = that.params.goodsName;
+				if (!name || name.length < 1) {
+				  return;
+				}
 				if (index !== -1) {
 				  // 已经存在,不用重复添加了
 				  return;

+ 2 - 1
shopping/searchhistory.vue

@@ -67,7 +67,8 @@
 				// 存储历史数据
 				let index = this.searchHistory.findIndex(item => item.name === this.keyword);
 				// console.log('index',index);
-				if (index !== -1) {
+				console.log('11',this.keyword.length<1);
+				if (index !== -1||this.keyword.length<1) {
 					this.goSearch(this.keyword)
 				  // 已经存在,不用重复添加了
 				  return;