- 博客(9)
- 收藏
- 关注
原创 es6 类实例属性的两种写法
es6 类实例属性的两种写法带参数可以传参,但是要多写一个constructorclass Person { constructor(name, age) { this.name = name this.age = age } speak() { console.log(`my name is ${this.name}, I am ${this.age} years o...
2020-04-20 11:13:05 579 1
原创 不使用new 运算符,尽可能找到获取对象的方法
var o = {}var o = function() {}// 使用Object构造器var o = new Object();// 使用function var o = new function f(){};// 使用methodvar o = Object.create(null);// 使用 ES6 classclass myObj { construc...
2020-01-08 15:41:20 326
原创 方法
/***@description向上找需要的父元素*@paramele初始元素*@paramtagname目标父元素的标签名*/exportfunctionfindParentEle(ele,tgName){if(!ele){returndocument.body}constparentEle=e...
2019-11-22 17:20:22 149
转载 使用 local storage 存储页面产生的数据结果
https://www.sunzhongwei.com/using-local-storage-save-page-data-results
2019-08-16 10:42:15 309
转载 scrollTop、offsetHeight和offsetTop
下面有每个属性详细的解释网页可见区域宽:document.body.clientWidth网页可见区域高:document.body.clientHeight网页可见区域宽:document.body.offsetWidth (包括边线的宽)网页可见区域高:document.body.offsetHeight (包括边线的宽)网页正文全文宽:document.body.scrol...
2019-08-16 10:32:10 180
原创 Window 尺寸
有三种方法能够确定浏览器窗口的尺寸。对于Internet Explorer、Chrome、Firefox、Opera 以及 Safari:window.innerHeight - 浏览器窗口的内部高度(包括滚动条) window.innerWidth - 浏览器窗口的内部宽度(包括滚动条)对于 Internet Explorer 8、7、6、5:document.documentE...
2019-08-16 10:20:45 224
转载 js常用的各种宽高clientHeight、scrollHeight、offsetHeight
一、宽高 (1)clientHeight、clientWidth→元素宽高(height+padding,不包含边框),可以理解为元素可视区域高度 (2)offsetHeight、offectWidth→元素宽高(height+padding+border,包含边框),可以理解为元素的可视高度 (3)scrollHeight、scrollWidth→元素宽高(内容的实...
2019-08-16 10:11:03 367
转载 javascript时间戳和日期字符串相互转换
"http://www.w3.org/1999/xhtml">"Content-Type" content="text/html; charset=utf-8" />"text/javascript">// 获取当前时间戳(以s为单位)var timestamp = Date.parse(new Date());timestamp = timestamp / 1000;//当前时间戳
2017-08-24 12:14:52 229
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人