cyy-tool
平时常用的一些函数和方法
使用示例
// DOM 元素全部加载完成; // 确保页面中 js/css 完全加载const file = 'xxx.js';; // url 上面获取参数对应的值// 当前 url: https://www.baidu.com/?openId=1234abcdconst openId = ;console; // 1234abcd // 返回一个在特点范围内的随机数字// 需求:随机返回 4-14 范围内的数字; // 鼠标滚轮事件const oDiv = document;; // 判断对象是否为空,true -> json为空const json = {};; // true // 获取文件类型const file = 'xxx.js';; // js // 字符串间隔(字符串四位间隔); // 6225 8888 8888 8888; // 159 1234 1234 // 将小于10的数字前面加上'0'; // 05 // 时间格式转换; // 2017.12.26 10:09:27 // 字符串截取(多余的显示省略号); // 我我我我我我我我我我... // 数值添加千分位处理; // 1,234,567,890,456.00 // json 转成 urlconst json = name: 'abc' age: 18 school: '卧槽';; // name=abc&age=18&school=%E5%8D%A7%E6%A7%BD&t=0.7911412332962664 // 倒计时// html 元素// <div id="div1" class="class-div1"></div>// <div class="class-div1"></div>// <br>// <div id="div2"></div> const oShowTime1 = document;const countdownTimeSec1 = 10; // 调用方式一:从回调函数里面获取时间,自行决定显示方式 serverTimestamp: startTimestamp: / 1000 + countdownTimeSec1 * 1000 { oShowTime1innerHTML = timeday + '天' + timehour + '小时' + timemin + '分' + timesec + '秒'; } { console; }; // 输出:// 00天00小时00分09秒 // 调用方式二:设置好显示的 html 元素和自定义显示的格式 showTimeElement: '.class-div1' serverTimestamp: startTimestamp: / 1000 + countdownTimeSec1 * 1000 showTimeSymbol: day: '天' hour: '小时' min: '分' sec: '秒' { console; }; // 输出:// 00天00时00分06秒// 00天00时00分06秒