- 博客(44)
- 资源 (10)
- 收藏
- 关注
原创 JS去除JSON字符串各种空格、换行符
strJSON.replace(/\r\n/g,'').replace(/\n/g,'').replace(/\s+/g,'');如要去除双引号strJSON.replace(/"/g,'')
2022-04-13 09:51:17
6095
原创 JS树结构操作:查找、遍历、筛选、树结构和列表结构相互转换
一、遍历树结构1. 树结构介绍JS中树结构一般是类似于这样的结构:let tree = [ { id: '1', title: '节点1', children: [ { id: '1-1', title: '节点1-1' }, { id: '1-2', title: '节点1-2' } ] }, { id: '2', ...
2022-03-01 15:47:53
522
原创 递归目录文件夹批量把md文档中的图片转为base64
const fs = require('fs');const path = require('path');const dir = './src/file/productVersionFile/';const dirPath = '/file/productVersionFile/';//遍历目录得到文件信息// dir:遍历目录;dirPath用于和根目录拼接function walk(dir, dirPath) { var files = fs.readdirSync(dir); .
2021-11-23 19:57:45
272
原创 node.js 批量处理中文文件夹和中文文件名转码
const fs = require('fs');const path = require('path');const dir = './src/static/productVersionFile';const dirPath = '/static/productVersionFile/';//遍历目录得到文件信息function walk(dir, dirPath) { var files = fs.readdirSync(dir); files.forEach((file) =&g.
2021-11-18 16:05:00
559
原创 前端通用方法util.js
/** * 下载文件(url资源) */export const downLoadUrl = (url, name, ext?) => { try { let link = document.createElement('a'); link.download = `${name}${ext && `.${ext}`}`; link.href = url; link.click(); } catch (error) {}};/** *.
2021-04-21 11:36:37
326
原创 git命令
git clone 远程仓库地址; 拉取创建本地仓库git pull 拉取git checkout . 本地所有修改的。没有的提交的,都返回到原来的状态 git add . 不加参数默认为将修改操作的文件和未跟踪新添加的文件添加到git系统的暂存区,注意不包括删除git add -u . -u 表示将已跟踪文件中的修改和删除的文件添加到暂存区,不包括新增加的...
2019-08-15 14:08:00
183
原创 两个相等的数组,修改其中一个怎么做到不改变另外一个
//方法一:concat()用于连接两个或多个数组。该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本。let arrA = [1, 2, 3];let arrB = [].concat(arrA);console.log(arrA,arrB); //[1, 2, 3],[1, 2, 3]//如果改变arrA, arrB不会改变arrA.splice(0,1);conso...
2019-07-31 11:00:22
443
原创 js根据数组中对象的某个属性值进行去重
var arr = [ { from:'张三', to: '河南' }, { from:'王二', to: '阿里' }, { from:'王二', to: '杭州' }, { from:'王二', to: '山东' },]//有如上数组,想根据数组中的对象的from属性进行去重,如果from一样的话,重...
2019-05-30 20:58:22
12690
3
转载 js去掉数组中重复的对象
function deteleObject(obj) { var uniques = []; var stringify = {}; for (var i = 0; i < obj.length; i++) { var keys = Object.keys(obj[i]); keys.sort(function(a, b) { ...
2019-05-24 16:00:04
919
原创 css去除文本框偶然出现的选中蓝色底问题
-moz-user-select: none; /*火狐*/ -webkit-user-select: none; /*webkit浏览器*/ -ms-user-select: none; /*IE10*/ -khtml-user-select: none; /*早期浏览器*/ user-select: none;
2017-09-21 14:53:02
1415
原创 css盒子模型
box-sizing:border-box;-moz-box-sizing:border-box; /* Firefox */-webkit-box-sizing:border-box; /* Safari */content-box这是由 CSS2.1 规定的宽度高度行为。宽度和高度分别应用到元素的内容框。在宽度和高度之外绘制元素的内边距和边框。border-box为元素设定的宽度和高度
2017-09-21 14:38:48
271
转载 截图
$(document).ready( function(){ $(".example1").on("click", function(event) { event.preventDefault(); html2canvas(document.body, {
2017-06-13 08:54:49
282
原创 底部一直在最底部不管内容多少
Document body,html {margin: 0;padding: 0;font: 12px/1.5 arial;height:100%;}#content {min-height:100%;position: relative;}#main {padding: 10px;padding-bottom: 60px; }#footer {pos
2017-05-03 21:20:07
403
原创 footer一直在最底部不管内容多少内容多的时候挤下去
Document body,html {margin: 0;padding: 0;font: 12px/1.5 arial;height:100%;}#content {min-height:100%;position: relative;}#main {padding: 10px;padding-bottom: 60px; }#footer {pos
2017-05-03 12:30:34
1177
原创 jQuery 遍历 - each() 方法
遍历一个数组通常用$.each()来处理 例如:$.each([{name:"limeng",email:"xfjylimeng"},{name:"hehe",email:"xfjylimeng"}],function(i,n){alert("索引:"+i+"对应值为:"+n.name);});参数i为遍历索引值,n为当前的遍历对象.var arr1 = [ "o
2017-03-30 16:31:29
344
原创 去除前后空格符号
trim()去除前后空格var content=" 12121 "; content.trim();前面不支持可以用function trim(s) {return s.replace(/(^\s*)|(\s*$)/g, "");}字符串替换var link=4000\r\n;link = link.replace(/\r\n/g, "");
2017-03-30 15:56:54
1599
原创 倒计时
倒计时 $(function() { var ExpireTime="2017-03-30 12:23:11"; var SystemTime="2017-02-10 14:13:21"; clearInterval(window._runPayOrderCountDown
2017-03-30 14:37:41
245
原创 把字符串时间转换成苹果ios可用用的时间
new Date("2017-03-29 11:35".replace(/\-/g,'/').replace('.0',''))new Date("2017-03-29 11:35".replace(/\-/g,'/').replace('.0','')).getTime()
2017-03-29 14:03:11
382
原创 纯CSS绘制三角形(各种角度)
#triangle-up { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red;}#triangle-down { wid...
2017-03-23 20:47:39
487
原创 sublime应用
自带代码格式化快捷键设置 : {"keys": ["ctrl+shift+r"], "command": "reindent" , "args": {"single_line": false}}Emmet 快速简写插件,Package Control 直接安装即可汉化插件:chinese 安装之后在帮助里可以切换语言sublime浏览器预览插件SideBarEnhancements
2016-12-06 17:39:56
445
原创 json按时间排序
正序var data = {"rows": [{"name": "张三","time": "2011/4/1 0:00:00",},{"name": "李四","time": "2015/5/6 12:30:00",},{"name": "王五","time": "2012/10/1 22:10:00",},{"name": "赵六","time
2016-10-28 16:23:01
2707
转载 JS:字符串和数字之间的相互转换
字符串进行比较没有进行转换的话,小于10的可以正常比较,大于10的会出错。方法主要有三种转换函数、强制类型转换、利用js变量弱类型转换。1. 转换函数:js提供了parseInt()和parseFloat()两个转换函数。前者把值转换成整数,后者把值转换成浮点数。只有对String类型调用这些方法,这两个函数才能正确运行;对其他类型返回的都是NaN(No
2016-10-28 16:16:20
2281
原创 在JS中object和字符串转换
var obj = JSON.parse(str); //由JSON字符串转换为JSON对象 var last=obj.toJSONString(); //将JSON对象转化为JSON字符或者var last=JSON.stringify(obj); //将JSON对象转化为JSON字符
2016-10-19 17:32:13
3537
转载 JS获取当前页面名称
JS获取当前页面名称// 取当前页面名称(不带后缀名) function pageName() { var a = location.href; var b = a.split("/"); var c = b.slice(b.length-1, b.length).toString(String).split(".");
2016-09-20 10:12:25
2325
转载 js把毫秒转换为 xx小时xx分钟xx秒的通用方法
function MillisecondToDate(msd) { var time = parseFloat(msd) / 1000; if (null != time && "" != time) { if (time > 60 && time < 60 * 60) { time = parseInt(time / 60.0) + "分钟
2016-08-01 11:55:08
10766
原创 根据经纬度获取当前地址
//定位 function place(lat,lng){ $.get('http://ditu.google.cn/maps/api/geocode/json?latlng='+lat+','+lng+'&language=zh-CN&sensor=false',null,function(data){ console.log(data); // co
2016-08-01 11:50:48
868
转载 在移动端上用GIS开发利用html5获取经纬度并在google地图中查看
GIS开发利用html5获取经纬度并在google地图中查看在移动端上用<script type="text/javascript"src="http://ditu.googleapis.com/maps/api/js?key=AIzaSyCefZle2DqxF9i51PTfoZsZoOmvWzKYhF4&sensor=true">将下面的经纬度输入谷歌地图:纬度:经度:准
2016-08-01 11:41:16
1412
原创 css样式大全(整理版)
字体属性:(font)大小 {font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)行高 {line-height: normal;}(正常) 单位:PX、PD、EM粗细 {font-weight: b...
2015-12-13 18:06:16
322
转载 网页制作CSS命名规范整理
一、文件规范 1、文件均归档至约定的目录中。 具体要求通过豆瓣的CSS规范进行讲解: 所有的CSS分为两大类:通用类和业务类。通用的CSS文件,放在如下目录中: 基本样式库 /css/core 通用UI元素样式库 /css/lib JS组件相关样式库 /css/ui 业务类的CSS是指和具体产品相关的文件,放在如下目录中:
2015-10-12 16:19:01
422
转载 javascript实现判断鼠标的状态
function dclick() {form1.text.value = "您双击了页面!";} function Click() {form1.text.value += "您单击了页面";} function down() {form1.text.value = "您按下了鼠标";} function up() {form1.text.value = "您释放了鼠标
2015-09-17 12:30:37
915
原创 验证码倒计时代码
function on_msg_click() { var wattingSecond = 60; //倒计时时间60秒 var disabled = true; var verificationCodeInterval; if (disabled == false) {
2015-09-07 15:34:02
408
原创 获取url参数
获取url参数 document.location.href = "ExChangeInfo.html?id=" + id; function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
2015-09-07 15:27:16
332
转载 JS中apply和call的联系和区别
JS中有时常用到 apply 和 call 两个方法,搜索网上很多,整理如下,简单看看这两个联系和区别,联系:网上查到关于apply和call的定义:这两个方法都能劫持另外一个对象的方法,继承另外一个对象的属性.xxxFunction.apply(obj,args) 方法接收两个参数obj:这个对象将代替xxxFunction类里this对象,也即xxxFuncti
2015-09-07 15:09:39
248
转载 JavaScript(js)设置默认输入焦点(focus)
常常会在回复和引用里使用此功能,即单击回复或引用,如让输入焦点出现在留言输入框中,如果使用锚来定位,输入焦点就不能激活了。 javascript:document.getElementById("id").focus(); 或javascript:document.all.id.focus(); 或javascript:document.all.name.focus();
2015-09-07 15:07:14
2668
转载 JS实现倒计时(时、分,秒)
JS实现倒计时(时、分,秒) var interval = 1000; function ShowCountDown(year,month,day,divname) { var now = new Date(); var endDate = new Date(year, month-1, day); var leftTime=endDate.getTime()-now
2015-09-07 15:06:02
766
转载 js 格式化时间日期函数小结
js 格式化时间日期函数小结Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinut
2015-09-07 15:03:35
1778
HTML5 截图上传
2015-09-07
svn 64位 汉化包
2014-11-05
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人