![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JS
哥伤透了心
这个作者很懒,什么都没留下…
展开
-
JS判断对象是否为空
1.Object.keys(obj).lengthvar obj = {};if (Object.keys(obj).length == 0) { console.log("对象为空");}else { console.log("对象不为空");}2.JSON.stringify()var obj = {};if(JSON.stringify(obj)=== '{}') { console.log("对象为空");}else { console.log("对象不为空原创 2021-03-26 19:15:27 · 104 阅读 · 0 评论 -
JS获取N天前的日期(number为负数即为N天后日期)
getBeforeDate(number) { const num = number; const date = new Date(); let year = date.getFullYear(); let mon = date.getMonth() + 1; let day = date.getDate(); if (day <= num) { if (mon > 1) { mon = mon - 1; } else { year = year - 1;原创 2021-03-14 02:22:04 · 280 阅读 · 0 评论 -
uni-app 中使用md5加密
1.新建md5.js文件/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet原创 2021-02-01 21:54:55 · 1253 阅读 · 1 评论 -
JS获取当前时间戳(10位数)
function timest() { var tmp = Date.parse( new Date() ).toString(); tmp = tmp.substr(0,10); return tmp;}原创 2021-02-01 19:36:09 · 1110 阅读 · 0 评论 -
Json对象转换成String字符串方法
JSON.stringify(jsonstr);原创 2021-02-01 19:28:56 · 1291 阅读 · 0 评论 -
string类型转换成Json对象方法
JSON.parse(jsonstr);原创 2021-02-01 19:30:22 · 1218 阅读 · 0 评论