定义全局数据过滤方法
Showing
2 changed files
with
34 additions
and
0 deletions
src/libs/fliter.js
0 → 100644
1 | import Vue from "vue"; | ||
2 | //定义key-value过滤方法 | ||
3 | function createFilter(filterName, dataArray) { | ||
4 | return Vue.filter(filterName, function(val) { | ||
5 | let label = ""; | ||
6 | let arr = dataArray; | ||
7 | arr.forEach((item) => { | ||
8 | if (item.value == val) { | ||
9 | return (label = item.label); | ||
10 | } | ||
11 | }); | ||
12 | return label; | ||
13 | }); | ||
14 | } | ||
15 | //时间格式过滤 | ||
16 | Vue.filter("timeFilter", function(timeStr) { | ||
17 | if (timeStr) { | ||
18 | return timeStr.substring(0, 10); | ||
19 | } | ||
20 | }); | ||
21 | |||
22 | //数据类型过滤 | ||
23 | let bdcLxArray = [ | ||
24 | { | ||
25 | label: "宗地", | ||
26 | value: "zd", | ||
27 | }, | ||
28 | { | ||
29 | label: "自然幢", | ||
30 | value: "zrz", | ||
31 | }, | ||
32 | ]; | ||
33 | createFilter("bdcLxFilter", bdcLxArray); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -13,6 +13,7 @@ import 'quill/dist/quill.snow.css' | ... | @@ -13,6 +13,7 @@ import 'quill/dist/quill.snow.css' |
13 | import 'quill/dist/quill.bubble.css' | 13 | import 'quill/dist/quill.bubble.css' |
14 | // 将富文本编译器 注册为全局组件 | 14 | // 将富文本编译器 注册为全局组件 |
15 | Vue.use(VueQuillEditor) | 15 | Vue.use(VueQuillEditor) |
16 | import "./libs/fliter"; //引入全局过滤器 | ||
16 | // 让IE11支持Vue-router跳转功能 | 17 | // 让IE11支持Vue-router跳转功能 |
17 | if ( | 18 | if ( |
18 | '-ms-scroll-limit' in document.documentElement.style && | 19 | '-ms-scroll-limit' in document.documentElement.style && | ... | ... |
-
Please register or sign in to post a comment