fliter.js 603 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",
	},
];
createFilter("bdcLxFilter", bdcLxArray);