js_ryl 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc CHANGED
@@ -7,14 +7,5 @@
7
7
  }
8
8
  ],
9
9
  "stage-3"
10
- ],
11
- "plugins": [
12
- [
13
- "component",
14
- {
15
- "libraryName": "element-ui",
16
- "styleLibraryName": "theme-chalk"
17
- }
18
- ]
19
10
  ]
20
11
  }
package/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
  5.运算符 -- num
16
16
  6.复制文本信息 -- copy //这是js版本,如果有 componen_ryl,可直接使用指令 v-copy
17
17
  7.对象深拷贝 -- deepCopy
18
+ 8.验证码 -- verCode
19
+ 9.table中的数据补全方法 -- filterTable
18
20
 
19
21
  # 使用方法:
20
22
 
@@ -105,6 +107,7 @@
105
107
 
106
108
  #7. 对象或数组的深拷贝 -- deepCopy
107
109
 
110
+ #第一个参数默认为: {}, 第二个参数为:数据源
108
111
  let obj2 = deepCopy({},obj)
109
112
 
110
113
  # 如:
@@ -148,6 +151,12 @@
148
151
  verCode.PhoneCodeClear()
149
152
  }
150
153
 
154
+ #9.table中的数据补全方法 -- filterTable
155
+
156
+ # 第一个参数为:数据源,第二个参数选填(为补全的符号,默认为 -- )
157
+ let list = filterTable(data)
158
+
159
+
151
160
 
152
161
  # serve with hot reload at localhost:8080
153
162
  # npm run dev
@@ -162,6 +171,8 @@
162
171
  #1.0.11: 添加对象或数组的深拷贝方法
163
172
  #1.0.12: number 方法 加 减 小数点后2位调整
164
173
  #1.0.15: 结构调整,把验证码效果,从 正则 中提取出来
174
+ #1.0.16: 剔除不用的包,如element
175
+ #1.0.17: 添加 数据补全方法 如:table中有数据为空时,自动补全 ‘--’ 符号
165
176
  ```
166
177
 
167
178
  For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
package/dist/build.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("js_ryl",[],e):"object"==typeof exports?exports.js_ryl=e():t.js_ryl=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=1)}([function(t,e,n){"use strict";var r={throole:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=0;return function(){var r=this,o=Date.now();o-n>e&&(t.call(r,arguments),n=o)}},debounce:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=null;return function(){var r=arguments,o=this;clearTimeout(n),n=setTimeout(function(){t.apply(o,r)},e)}}};e.a=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=n(3),i=n(4),u=n(0),a=n(5),c=n(6),l=n(7),s=n(8);e.default={reg:r.a,time:o.a,cookie:i.a,fun:u.a,num:a.a,copy:c.a,deepCopy:l.a,verCode:s.a}},function(t,e,n){"use strict";var r={Phone:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入手机号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"手机号码格式有误",r=/^[1][3,4,5,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},Email:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入邮箱",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"邮箱格式有误",r=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;return t?!!r.test(t)||n:e},IdCard:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入身份证号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"身份证号码格式有误",r=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;return t?!!r.test(t)||n:e},Common:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入包含数字、字母以及下划线的内容",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"只能包含数字、字母以及下划线",r=/^[a-zA-Z0-9_]+$/;return t?!!r.test(t)||n:e},QQ:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入QQ号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"QQ号码格式错误",r=/^[1-9][0-9]{4,10}$/gim;return t?!!r.test(t)||n:e},Money:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入金额(最多保留2位小数点)",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"金额格式错误",r=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;return t?!!r.test(t)||n:e}};e.a=r},function(t,e,n){"use strict";function r(t){return t<10?"0"+t:t}var o={toDate:function(t,e){var n="";n=10==String(t).length?new Date(1e3*t):new Date(t);var o=n.getFullYear(),i=n.getMonth()+1,u=n.getDate(),a=n.getHours(),c=n.getMinutes(),l=n.getSeconds();return"yyyy-MM-dd"==e?o+"-"+r(i)+"-"+r(u):"yyyy-MM-dd HH:mm"==e?o+"-"+r(i)+"-"+r(u)+" "+r(a)+":"+r(c):o+"-"+r(i)+"-"+r(u)+" "+r(a)+":"+r(c)+":"+r(l)},toStamp:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=new Date(t.replace(/-/g,"/")).getTime().toString();return 10==e&&(n=n.substr(0,10)),parseInt(n)},getNow:function(){var t=(new Date).getTime();return o.toDate(t)}};e.a=o},function(t,e,n){"use strict";var r={set:function(t,e,n){n=n||{};var r=n.path?";Path="+n.path:"",o="";if(n.expires){o=";expires="+(10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires)).toGMTString()}document.cookie=t+"="+e+r+o},get:function(t){for(var e=document.cookie,n=e.split("; "),r=0;r<n.length;r++)if(n[r].split("=")[0]===t)return n[r].split("=")[1];return""},remove:function(t,e){e=e||{},e.expires=-1,r.set(t,null,e)}};e.a=r},function(t,e,n){"use strict";var r=(n(0),function(t){var e=0;try{t=Number(t);var n=t.toString().toUpperCase();if(2===n.split("E").length){var r=!1;2===n.split(".").length&&(n=n.split(".")[1],0!==parseInt(n.split("E")[0])&&(r=!0));var o=n.split("E");r&&(e=o[0].length),e-=parseInt(o[1])}else 2===n.split(".").length&&0!==parseInt(n.split(".")[1])&&(e=n.split(".")[1].length)}catch(t){throw t}finally{return(isNaN(e)||e<0)&&(e=0),e}}),o=function(t){t=Number(t);var e=r(t),n=t.toString().toUpperCase();return 2===n.split("E").length?Math.round(t*Math.pow(10,e)):Number(n.replace(".",""))},i=function(t,e,n,r){var o=0;switch(t){case"add":o=e+n;break;case"sub":o=e-n;break;case"div":o=e/n;break;case"mul":o=e*n}return Math.abs(r-o)>1?o:r},u={NumFilter:function(t){var e=String(t).indexOf(".")+1,n=String(t).length-e;return n>0&&n>=3&&(t=Math.floor(100*t)/100),t},add:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,u;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}u=Math.pow(10,Math.max(n,o));var a=(this.mul(t,u)+this.mul(e,u))/u;return i("add",t,e,a)},sub:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,u;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}u=Math.pow(10,Math.max(n,o));var a=Number((this.mul(t,u)-this.mul(e,u))/u);return i("sub",t,e,a)},div:function(t,e){t=Number(t),e=Number(e);var n,u,a=0,c=0;try{a=r(t)}catch(t){}try{c=r(e)}catch(t){}n=o(t),u=o(e);var l=this.mul(n/u,Math.pow(10,c-a));return i("div",t,e,l)},mul:function(t,e){t=Number(t),e=Number(e);var n=0,u=t.toString(),a=e.toString();try{n+=r(u)}catch(t){}try{n+=r(a)}catch(t){}var c=o(u)*o(a)/Math.pow(10,n);return i("mul",t,e,c)}};e.a=u},function(t,e,n){"use strict";function r(t,e){var n=document.createElement("input");n.setAttribute("readonly","readonly"),n.setAttribute("value",t),document.body.appendChild(n),document.execCommand("copy")?(n.select(),document.execCommand("copy"),e({code:200,msg:"复制成功"})):e({code:100,msg:"当前浏览器不支持,请更换浏览器后重试"}),document.body.removeChild(n)}e.a=r},function(t,e,n){"use strict";function r(t,e){var n=t||{};for(var i in e)"object"===o(e[i])?(n[i]=e[i].constructor===Array?[]:{},r(n[i],e[i])):n[i]=e[i];return n}e.a=r;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}},function(t,e,n){"use strict";var r=!1,o=null,i="",u=null,a={PhoneCode:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"后重新获取";if(i=t.target.innerText,u=t,!r){r=!0,t.target.innerText=n-1+"s"+a;var c=n-1;o=setInterval(function(){c--,c<=0?(t.target.innerText=i,e.PhoneCodeClear()):t.target.innerText=c+"s"+a},1e3)}},PhoneCodeClear:function(){r=!1,u&&(u.target.innerText=i),clearInterval(o)},phoneCodeStatus:function(){return r}};e.a=a}])});
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("js_ryl",[],e):"object"==typeof exports?exports.js_ryl=e():t.js_ryl=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=1)}([function(t,e,n){"use strict";var r={throole:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=0;return function(){var r=this,o=Date.now();o-n>e&&(t.call(r,arguments),n=o)}},debounce:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=null;return function(){var r=arguments,o=this;clearTimeout(n),n=setTimeout(function(){t.apply(o,r)},e)}}};e.a=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=n(3),i=n(4),u=n(0),a=n(5),c=n(6),l=n(7),s=n(8),f=n(9);e.default={reg:r.a,time:o.a,cookie:i.a,fun:u.a,num:a.a,copy:c.a,deepCopy:l.a,verCode:s.a,filterTable:f.a}},function(t,e,n){"use strict";var r={Phone:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入手机号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"手机号码格式有误",r=/^[1][3,4,5,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},Email:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入邮箱",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"邮箱格式有误",r=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;return t?!!r.test(t)||n:e},IdCard:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入身份证号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"身份证号码格式有误",r=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;return t?!!r.test(t)||n:e},Common:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入包含数字、字母以及下划线的内容",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"只能包含数字、字母以及下划线",r=/^[a-zA-Z0-9_]+$/;return t?!!r.test(t)||n:e},QQ:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入QQ号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"QQ号码格式错误",r=/^[1-9][0-9]{4,10}$/gim;return t?!!r.test(t)||n:e},Money:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入金额(最多保留2位小数点)",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"金额格式错误",r=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;return t?!!r.test(t)||n:e}};e.a=r},function(t,e,n){"use strict";function r(t){return t<10?"0"+t:t}var o={toDate:function(t,e){var n="";n=10==String(t).length?new Date(1e3*t):new Date(t);var o=n.getFullYear(),i=n.getMonth()+1,u=n.getDate(),a=n.getHours(),c=n.getMinutes(),l=n.getSeconds();return"yyyy-MM-dd"==e?o+"-"+r(i)+"-"+r(u):"yyyy-MM-dd HH:mm"==e?o+"-"+r(i)+"-"+r(u)+" "+r(a)+":"+r(c):o+"-"+r(i)+"-"+r(u)+" "+r(a)+":"+r(c)+":"+r(l)},toStamp:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=new Date(t.replace(/-/g,"/")).getTime().toString();return 10==e&&(n=n.substr(0,10)),parseInt(n)},getNow:function(){var t=(new Date).getTime();return o.toDate(t)}};e.a=o},function(t,e,n){"use strict";var r={set:function(t,e,n){n=n||{};var r=n.path?";Path="+n.path:"",o="";if(n.expires){o=";expires="+(10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires)).toGMTString()}document.cookie=t+"="+e+r+o},get:function(t){for(var e=document.cookie,n=e.split("; "),r=0;r<n.length;r++)if(n[r].split("=")[0]===t)return n[r].split("=")[1];return""},remove:function(t,e){e=e||{},e.expires=-1,r.set(t,null,e)}};e.a=r},function(t,e,n){"use strict";var r=(n(0),function(t){var e=0;try{t=Number(t);var n=t.toString().toUpperCase();if(2===n.split("E").length){var r=!1;2===n.split(".").length&&(n=n.split(".")[1],0!==parseInt(n.split("E")[0])&&(r=!0));var o=n.split("E");r&&(e=o[0].length),e-=parseInt(o[1])}else 2===n.split(".").length&&0!==parseInt(n.split(".")[1])&&(e=n.split(".")[1].length)}catch(t){throw t}finally{return(isNaN(e)||e<0)&&(e=0),e}}),o=function(t){t=Number(t);var e=r(t),n=t.toString().toUpperCase();return 2===n.split("E").length?Math.round(t*Math.pow(10,e)):Number(n.replace(".",""))},i=function(t,e,n,r){var o=0;switch(t){case"add":o=e+n;break;case"sub":o=e-n;break;case"div":o=e/n;break;case"mul":o=e*n}return Math.abs(r-o)>1?o:r},u={NumFilter:function(t){var e=String(t).indexOf(".")+1,n=String(t).length-e;return n>0&&n>=3&&(t=Math.floor(100*t)/100),t},add:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,u;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}u=Math.pow(10,Math.max(n,o));var a=(this.mul(t,u)+this.mul(e,u))/u;return i("add",t,e,a)},sub:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,u;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}u=Math.pow(10,Math.max(n,o));var a=Number((this.mul(t,u)-this.mul(e,u))/u);return i("sub",t,e,a)},div:function(t,e){t=Number(t),e=Number(e);var n,u,a=0,c=0;try{a=r(t)}catch(t){}try{c=r(e)}catch(t){}n=o(t),u=o(e);var l=this.mul(n/u,Math.pow(10,c-a));return i("div",t,e,l)},mul:function(t,e){t=Number(t),e=Number(e);var n=0,u=t.toString(),a=e.toString();try{n+=r(u)}catch(t){}try{n+=r(a)}catch(t){}var c=o(u)*o(a)/Math.pow(10,n);return i("mul",t,e,c)}};e.a=u},function(t,e,n){"use strict";function r(t,e){var n=document.createElement("input");n.setAttribute("readonly","readonly"),n.setAttribute("value",t),document.body.appendChild(n),document.execCommand("copy")?(n.select(),document.execCommand("copy"),e({code:200,msg:"复制成功"})):e({code:100,msg:"当前浏览器不支持,请更换浏览器后重试"}),document.body.removeChild(n)}e.a=r},function(t,e,n){"use strict";function r(t,e){var n=t||{};for(var i in e)"object"===o(e[i])?(n[i]=e[i].constructor===Array?[]:{},r(n[i],e[i])):n[i]=e[i];return n}e.a=r;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}},function(t,e,n){"use strict";var r=!1,o=null,i="",u=null,a={PhoneCode:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"后重新获取";if(i=t.target.innerText,u=t,!r){r=!0,t.target.innerText=n-1+"s"+a;var c=n-1;o=setInterval(function(){c--,c<=0?(t.target.innerText=i,e.PhoneCodeClear()):t.target.innerText=c+"s"+a},1e3)}},PhoneCodeClear:function(){r=!1,u&&(u.target.innerText=i),clearInterval(o)},phoneCodeStatus:function(){return r}};e.a=a},function(t,e,n){"use strict";function r(t){return["",void 0,null].some(function(e){return e===t})}var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--",n=[];for(var o in t){for(var i={},u=Object.entries(t[o]),a=0;a<u.length;a++){var c=u[a];r(c[1])&&(c[1]=e),i[c[0]]=c[1]}n.push(i)}return n};e.a=o}])});
package/jsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@/*":["./src/*"]
6
+ },
7
+ "module": "EsNext"
8
+ },
9
+ "include": [
10
+ "src/**/*.js",
11
+ "src/**/*.jsx",
12
+ "src/**/*.vue",
13
+ ],
14
+ "exclude": [
15
+ "node_modules"
16
+ ]
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_ryl",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "private": false,
5
5
  "description": "自定义通用js",
6
6
  "author": "renyuliang <785788909@qq.com>",
@@ -10,14 +10,12 @@
10
10
  },
11
11
  "main": "dist/build.js",
12
12
  "dependencies": {
13
- "element-ui": "^2.15.1",
14
13
  "vue": "^2.6.12"
15
14
  },
16
15
  "devDependencies": {
17
16
  "@babel/plugin-transform-runtime": "^7.14.3",
18
17
  "babel-core": "^6.26.0",
19
18
  "babel-loader": "^7.1.5",
20
- "babel-plugin-component": "^1.1.1",
21
19
  "babel-preset-env": "^1.6.0",
22
20
  "babel-preset-stage-3": "^6.24.1",
23
21
  "cross-env": "^5.0.5",
@@ -27,23 +25,11 @@
27
25
  "sass-loader": "^7.3.1",
28
26
  "style-loader": "^0.23.1",
29
27
  "url-loader": "^0.6.2",
30
- "vue-cli-plugin-element": "~1.0.1",
31
28
  "vue-loader": "^13.0.5",
32
29
  "vue-template-compiler": "^2.6.12",
33
30
  "webpack": "^3.6.0",
34
31
  "webpack-dev-server": "^2.9.1"
35
32
  },
36
- "babel": {
37
- "plugins": [
38
- [
39
- "component",
40
- {
41
- "libraryName": "element-ui",
42
- "styleLibraryName": "theme-chalk"
43
- }
44
- ]
45
- ]
46
- },
47
33
  "browserslist": [
48
34
  "> 1%",
49
35
  "last 2 versions",
package/src/App2.vue CHANGED
@@ -21,6 +21,15 @@
21
21
  <!-- <button @click="phoneCode($event)">验证码</button> -->
22
22
  <a href="javascript:;" @click="phoneCode($event)">验证码</a>
23
23
  <a href="javascript:;" @click="phoneCodeExit()">清空验证码</a>
24
+ <br>
25
+ <br>
26
+ <ul>
27
+ <li v-for="(item,index) in list" :key="index">
28
+ <span>{{item.name}}</span>
29
+ <span>{{item.age}}</span>
30
+ <span>{{item.sex}}</span>
31
+ </li>
32
+ </ul>
24
33
  </div>
25
34
  </template>
26
35
  <script>
@@ -32,16 +41,35 @@ import num from "./number";
32
41
  import copy from "./copy";
33
42
  import deepCopy from "./deepCopy";
34
43
  import verCode from "./verCode";
44
+ import filterTable from "./filterTable";
35
45
  export default {
36
46
  data() {
37
47
  return {
38
48
  name: "",
49
+ list: [
50
+ {
51
+ name:'d',
52
+ age:99,
53
+ sex:'男'
54
+ },
55
+ {
56
+ name:null,
57
+ age:'',
58
+ sex: '女'
59
+ },
60
+ {
61
+ name:'hf',
62
+ age:1,
63
+ sex:''
64
+ },
65
+ ]
39
66
  };
40
67
  },
41
68
  // directives: {
42
69
  // LazyLoad,
43
70
  // },
44
71
  mounted() {
72
+ this.list = filterTable(this.list)
45
73
  console.log(time.toStamp("2021-06-02 18:17:02"), "当前时间戳");
46
74
  console.log(time.toDate(1622623502), "当前时间");
47
75
  console.log(time.getNow(), "系统当前时间");
@@ -0,0 +1,26 @@
1
+ // table中的数据 空值 转为 --
2
+
3
+ // 自定义需要状态的条件
4
+ function filterType(i){
5
+ let type = ['',undefined,null]
6
+ return type.some(v=>{
7
+ return v === i
8
+ })
9
+ }
10
+ const filterTable = (data,params="--")=>{
11
+ let newArr = []
12
+ for (let key in data) {
13
+ let obj = {}
14
+ let re = Object.entries(data[key])
15
+ for (let i = 0; i < re.length; i++) {
16
+ let d= re[i]
17
+ if (filterType(d[1])) {
18
+ d[1] = params
19
+ }
20
+ obj[d[0]]=d[1]
21
+ }
22
+ newArr.push(obj)
23
+ }
24
+ return newArr
25
+ }
26
+ export default filterTable
package/src/index.js CHANGED
@@ -15,6 +15,8 @@ import copy from "./copy";
15
15
  import deepCopy from "./deepCopy";
16
16
  // 验证码
17
17
  import verCode from "./verCode";
18
+ // table中 空值 转为 --
19
+ import filterTable from "./filterTable";
18
20
 
19
21
  export default {
20
22
  reg,
@@ -24,5 +26,6 @@ export default {
24
26
  num,
25
27
  copy,
26
28
  deepCopy,
27
- verCode
29
+ verCode,
30
+ filterTable
28
31
  };