fliter.js 773 Bytes
import Vue from "vue";
//定义key-value过滤方法
function createFilter(filterName, dataArray) {
	return Vue.filter(filterName, function(val) {
		let label = "";
		let arr = dataArray;
		arr.forEach((item) => {
			if (item.value == val) {
				return (label = item.label);
			}
		});
		return label;
	});
}
//时间格式过滤
Vue.filter("timeFilter", function(timeStr) {
	if (timeStr) {
		return timeStr.substring(0, 10);
	}
});

//数据类型过滤
let bdcLxArray = [
	{
		label: "宗地",
		value: "zd",
	},
	{
		label: "自然幢",
		value: "zrz",
	},
	{
		label: "户(预测)",
		value: "h0",
	},
	{
		label: "户(实测)",
		value: "h1",
	},
	{
		label: "户",
		value: "h",
	},
	{
		label: "多幢",
		value: "dz",
	},
];
createFilter("bdcLxFilter", bdcLxArray);