javascript
Artemis_Wang
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
vue-cli不同环境配置与构建
背景在h5应用开发中,仅有一个配置文件(static/js/config.js)用于维护环境变量,这样当从tst分支merge代码到prd分支时,会将prd环境的配置文件中prd环境地址覆盖成tst环境地址,需要再修改为prd环境地址后并注释掉vconsole提交代码至master。解决办法1. 将环境变量抽离出来分别存到三套环境(prd/tst/dev)的配置文件中,配置文件放在根目录下开发环境,文件名:.env.developmentNODE_ENV = 'development'原创 2021-08-27 09:49:28 · 648 阅读 · 0 评论 -
获取移动端H5页面中元素的位置
let elm = document.getElementById('elm')elm.getBoundingClientRect().top // 获取当前元素与viewport上边的距离elm.getBoundingClientRect().bottom // 获取当前元素与viewport下边的距离elm.getBoundingClientRect().left // 获取当前元素与viewport左边的距离elm.getBoundingClientRect().right // 获取.原创 2021-07-24 15:46:29 · 1214 阅读 · 0 评论 -
移动端H5触屏事件
移动端H5主要包括 3 种触屏事件touchstart:手指接触屏幕时触发 touchmove:已接触的手指开始移动后触发 touchend:手指离开屏幕时触发解释: 每个触摸事件对象都包括touches属性,用于描述目前位于屏幕上所有手指的信息 单指操作中,使用 touches[0] 即可注:在vant组件上直接调用touchmove事件可能不生效,替换为touchmove.native即可...原创 2021-07-24 15:41:06 · 1254 阅读 · 0 评论 -
bind、call、apply的实现
bind 的实现Function.prototype.myBind = function (that, ...args) { let fn = this return function () { return fn.apply(that, [...args, ...arguments]) }} call 的实现Function.prototype.myCall = function (that, ...args) { that.fn = t...原创 2021-07-22 19:07:16 · 179 阅读 · 0 评论 -
深拷贝浅拷贝
2 种浅拷贝 3 种深拷贝(包括手写实现) 2 种浅拷贝//1 let b = Object.assign({}, a)//2let b = {...a} 3 种深拷贝(包括手写实现)1. JSON.parse方法let b = JSON.parse(JSON.stringify(a))缺点:1. 会忽略undefined、Symbol 2. 不能序列化函数 3. ...原创 2021-07-21 13:41:57 · 121 阅读 · 0 评论 -
isPrototypeOf和instanceof区别与二者实现方法
isPrototypeOf 的两个变量都是 对象 ,用于检测调用此方法的对象是否存在于指定对象的原型链中 instanceof 的两个变量分别是 对象 和 构造函数 ,用于检测构造函数的原型是否存在于指定对象的原型链中isPrototypeOf实现...原创 2021-07-20 13:19:15 · 507 阅读 · 0 评论 -
Object方法总结
3 个与原型有关方法 2 个对象方法 3 个禁止扩展属性 17个Object方法 3 个与原型有关方法Object.isPrototypeOf()Object.getPrototypeOf()Object.setPrototypeOf() 2 个对象方法object.hasOwnProperty(name)object.propertyIsEnumerable() 3 个禁止扩展...原创 2021-07-20 09:34:48 · 161 阅读 · 0 评论 -
instanceof的实现
instanceof用于判断左侧参数的原型链中是否能找到右侧参数的原型具体实现如下:function instanceof1(left, right) { // instanceof是保留字 let prototype = right.prototype left = left.__proto__ while (left) { if (left === prototype) return true left = left.__proto__ } return原创 2021-07-20 09:14:06 · 344 阅读 · 0 评论 -
JS找最大值
// 找最大值Math.prototype.min.apply(Math,[1,2,3,4])Math.prototype.min.call(Math,1,2,3,4,5)// 找最小值Math.prototype.max.apply(Math,[1,2,3,4])Math.prototype.max.call(Math,1,2,3,4,5)原创 2021-07-19 15:51:33 · 444 阅读 · 0 评论 -
前端数组array方法总结
5 个纯函数 8 个遍历方法 5 个纯函数array.map() //1array.filter() //2array.concat(item...) //3array.slice(start, end) //4array.sort(compareFn) //5 8 个遍历方法array.every() //1array.forEach() //2array.find() //3array.findIndex() //4arra...原创 2021-07-19 15:26:08 · 599 阅读 · 0 评论 -
前端数据类型考点
6种基本类型 1种复杂类型 7个假值 7个typeof类型 6 种基本类型boolean undefined null number string symbol 1 种复杂类型object 7 个假值false undefined null 0 -0 NaN '' 7 个typeof值boolean undefined number string symbol function object...原创 2021-07-19 15:12:21 · 134 阅读 · 0 评论
分享