摘要: 同步与异步 同步:等待结果异步:不等待结果 注意,异步常常伴随回调一起出现,但是异步不是回调,回调也不一定是异步 如下代码就是同步,只要fn内部的循环完毕才能执行下面的代码 异步代码 定时器就相当于浏览器设置了一个闹钟 之后继续执行 闹钟到了时间再去执行相应的代码 前端经常遇到的异步 你应该在图片加 阅读全文
posted @ 2018-12-20 17:21 我自是年少 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 一个父元素div,一个未知宽度、高度的子元素div [上下左右居中方法总结] 常用Hack的技巧: 两行溢出省略,兼容ie的 用纯CSS创建一个三角形的原理是什么? 把上、左、右三条边隐藏掉(颜色设为 transparent) CSS3 线性渐变 background: linear-gradien 阅读全文
posted @ 2018-12-20 16:17 我自是年少 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序 var arr = [5,8,3,6,9] for(var i=0;i<arr.length;i++){ for(var j=i+1;j<arr.length;j++){ if(arr[i]>arr[j]){ var temp temp=arr[i]; arr[i]=arr[j]; arr 阅读全文
posted @ 2018-12-20 15:47 我自是年少 阅读(1618) 评论(0) 推荐(0) 编辑
摘要: 一个页面从输入url到页面显示加载完成,这个过程发生了什么? 1.浏览器根据请求的URL交给DNS域名解析,找到真实的IP,向服务器发起请求。 2.服务器交给后台处理完成后返回数据,浏览器接收文件(html,css,js图像等)、 3.浏览器对加载到的资源进行语法解析,建立对应的内部数据结构(如ht 阅读全文
posted @ 2018-12-20 15:32 我自是年少 阅读(733) 评论(0) 推荐(0) 编辑
摘要: // 获取当前日期 function getLocalDate() { var times = getYMDHMS(new Date()); return times.year + "-" + times.month + "-" + times.date; } // 获取当前年月 function getLocalYearMonth() { var times = ge... 阅读全文
posted @ 2018-12-20 15:15 我自是年少 阅读(5091) 评论(0) 推荐(0) 编辑
摘要: 路由对象 在使用了 vue-router 的应用中,路由对象会被注入每个组件中,赋值为 this.$route ,并且当路由切换时,路由对象会被更新。 路由对象暴露了以下属性: $route.path 字符串,等于当前路由对象的路径,会被解析为绝对路径,如 "/home/news" 。 $route 阅读全文
posted @ 2018-12-20 15:07 我自是年少 阅读(719) 评论(0) 推荐(0) 编辑
摘要: 在页面一开始加上一个全局的函数: activated: function () { this.$setgoindex() } 这个函数是这样的,判断当前页面的历史记录是不是小于等于1,如果小于等于1,说明这个页面没有可以返回的上一页,如果没有可以返回的上一页,就给地址栏加上一个goindex=tru 阅读全文
posted @ 2018-12-20 15:01 我自是年少 阅读(4372) 评论(0) 推荐(0) 编辑
摘要: // 根据时间戳获取年月日时分秒 function getYMDHMS(time) { var year = time.getFullYear(), month = time.getMonth() + 1, date = time.getDate(), hours = time.getHours() 阅读全文
posted @ 2018-12-20 14:58 我自是年少 阅读(12656) 评论(0) 推荐(0) 编辑
摘要: 经常用到算数的时候,可以直接用; 1 // 除法函数 2 function accDiv(arg1, arg2) { 3 var t1 = 0, 4 t2 = 0, 5 r1, r2; 6 try { t1 = arg1.toString().split(".")[1].length } catch (e) {} 7 try {... 阅读全文
posted @ 2018-12-20 14:57 我自是年少 阅读(1404) 评论(0) 推荐(0) 编辑
摘要: document.oncontextmenu = function () {//点右键,啥反应都没有了 return false; } document.onkeydown = function () { // ctrl+c 也没有用了,只对ie有效。firefox和chrome不行 if (eve 阅读全文
posted @ 2018-12-20 11:56 我自是年少 阅读(431) 评论(0) 推荐(0) 编辑
摘要: //获取cookie export const getCookie = (name) => { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) ret 阅读全文
posted @ 2018-12-20 11:53 我自是年少 阅读(251) 评论(0) 推荐(0) 编辑
摘要: // 解决 堆栈 出现的父对象和子对象相关联的问题 (三种方法) // 深拷贝 function dishesStackHandle(person, current) { var current = current || {}; for (var i in person) { if (typeof 阅读全文
posted @ 2018-12-20 11:52 我自是年少 阅读(342) 评论(0) 推荐(0) 编辑
摘要: # eg http://view.officeapps.live.com/op/view.aspx?src=<Document Location> #demo <a href="http://api.idocv.com/view/url?url=http%3A%2F%2Fapi.idocv.com% 阅读全文
posted @ 2018-12-20 11:34 我自是年少 阅读(1050) 评论(0) 推荐(0) 编辑