js
遇见一个人流泪
这个作者很懒,什么都没留下…
展开
-
对象数组 排序
list.sort((a, b) => { return a.name.localeCompare(b.name, 'zh');});原创 2018-11-23 17:49:24 · 364 阅读 · 0 评论 -
canvas绘制饼图带百分比
const canvas = document.getElementById(target);const ctx = canvas.getContext('2d');const startPoint = 1.5 * Math.PI;if (percent > 0) { ctx.fillStyle = '#95B3D7'; ctx.strokeStyle = '#95B3D7';...原创 2018-11-14 10:59:05 · 1100 阅读 · 0 评论 -
setTimeout延时0毫秒的作用
浏览器会在执行完当前任务队列中的任务,再执行setTimeout队列中积累的任务。通过设置任务在延迟0毫秒后执行,就能改变任务执行的先后顺序,延迟该任务发生,使之异步执行。...原创 2018-11-06 10:46:44 · 1882 阅读 · 0 评论 -
canvas 裁剪签名图片 去除多余的空白
var canvas = document.createElement("canvas");canvas.width = sWidth;canvas.height = sHeight;var context= canvas.getContext("2d");context.font = "20px Georgia";context.textAlign = 'center'; //文本水平对原创 2017-05-04 15:02:54 · 4437 阅读 · 2 评论 -
各种疑难杂症
springMVC传递数组类型时,需要加上@RequestParam(value = "ids[]") int[] ids注:ids后面的[]一定要加上,不然没法匹配原创 2017-03-31 11:11:05 · 6380 阅读 · 1 评论 -
实用技巧集合
onkeydown=”if(event.keyCode==13) return false;”原创 2017-06-05 11:49:08 · 263 阅读 · 0 评论 -
各种特异功能
$(function(){ pushHistory(); window.addEventListener("popstate", function(e) { history.go(-2); }, false); function pushHistory() { var state = { title:原创 2017-02-07 16:42:41 · 1635 阅读 · 0 评论 -
Html5 上传图片预览
$('#imageUpload').change(function(event) { var files = event.target.files, file; for(var i=0; i<files.length; i++){ file = files[i]; /* var URL = window.URL || window.webkitURL;原创 2016-12-26 15:12:41 · 289 阅读 · 0 评论 -
ajax content-Type注意事项
content-Type定义的是发送至服务器的数据类型,data-Type定义的是服务器返回的数据类型。 如果不指定 ContentType,默认为text/html,表单数据默认为application/x-www-form-urlencoded。我一般习惯将其设为application/json。需要注意的是: 如果使用的是get方式,那么以上三种做法都是可以的,因为ge原创 2016-12-14 10:00:26 · 7534 阅读 · 0 评论 -
关于for (var index in items)和for (var i = 0; i < items.length; i++)
前者循环的是属性,后者循环的才是数组。若项目中对数组属性进行了扩展,那切记不能使用前者,否则在循环数组时扩展的函数体也会被当做数据返回。原创 2017-01-19 17:47:48 · 6963 阅读 · 0 评论 -
判断时间间隔
最长10天const dateDiff = new Date(date[1]).getTime() - new Date(date[0]).getTime();const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000));if (dayDiff >= 10) {}最长6个月const startMonth = ne...原创 2018-11-26 14:27:14 · 341 阅读 · 0 评论