Browse Source

提取车辆类型到公用filter

gcz 4 years ago
parent
commit
56727733b7
2 changed files with 18 additions and 11 deletions
  1. 0 11
      pages/myCars/myCars.vue
  2. 18 0
      utils/filter.js

+ 0 - 11
pages/myCars/myCars.vue

@@ -178,17 +178,6 @@
 			}
 			
 		},
-		filters: {
-		  energyTpye(value) {
-			if (value === 1) {
-			  return '汽油车';
-			}else if (value === 2) {
-			  return '新能源';
-			} else {
-			  return '汽油车';
-			}
-		  },
-		},
 	}
 </script>
 

+ 18 - 0
utils/filter.js

@@ -109,4 +109,22 @@ Vue.filter("filterPayStatus",function(status){
 	
 });
 
+// 汽车类型
+Vue.filter("energyTpye",function(value){
+	status = Number(value);
+	switch (value){
+		case 1:
+			return '汽油车'
+			break;
+		case 2:
+			return '新能源'
+			break;
+		default:
+			return '汽油车'
+			break;
+	}
+	
+});
+
+