火狐浏览器下隐藏滚动条

转载自:http://jsfiddle.net/bizamajig/md27H

原理:父元素overflow:hidden;子元素中width宽度比父元素宽,多出的宽度即浏览器滚动条的宽度

<div id=”content”>
<div id=”scrollable”></div>
</div>


#content {
position: relative;
width: 200px;
height: 200px;
border: 1px solid black;
overflow: hidden;
}
#scrollable {
height: 200px;
width: 218px;
overflow-y: scroll;
}

this指向?

this is set according to how the method is called, and not according to how the method is written. So for obj.method(), this will be set to obj inside of method(). For obj.method.call(x), this inside of method() will be set to x. It is determined by how it’s called. What that also means is that if you pass it as a callback to e.g. onclick, this will be set to the global window object rather than what you expect.

参考1:https://stackoverflow.com/questions/13224620/the-this-keyword-returns-the-window-object-within-an-objects-prototype-in-jav

参考2:https://segmentfault.com/a/1190000008400124

JavaScript 函数中的 this 指向并不是在函数定义的时候确定的,而是在调用的时候确定的。换句话说,函数的调用方式决定了 this 指向

继续阅读this指向?

js-cookie设置有效期,天/时/分/秒

https://github.com/js-cookie/js-cookie/wiki/Frequently-Asked-Questions

安装:npm i js-cookie

const expires;

expires = 7; // 7天

expires = 0.5 // 半天(12h)

expires = 1/48; // 30分钟

expires = new Date(new Date().getTime() + 15 * 60 * 1000); // 15分钟

expires = new Date(new Date().getTime() + 60 * 1000); // 60秒

Cookies.set(name, value, { expires: expires });

微信分享地址传参时的问题

问题描述:当微信分享地址携带两个相同的参数时,请求地址中会携带两个参数,但是复制出来的地址却只携带了其中一个参数(导致定位问题失败)

附带替换参数值代码:

changeUrlKeyVal: function(key, val) {
  const href = location.href.split(“#”)[0];
  const pattern = key + ‘=([^&]*)’;
  const replaceText = key + ‘=’ + val;
  return href.match(pattern) ? href.replace(eval(‘/(‘ + key + ‘=)([^&]*)/gi’), replaceText) : (href.match(‘[\?]’) ?href + ‘&’ + replaceText : href + ‘?’ + replaceText);
}

注意!!!谨记!!!

 

npm报错:Unexpected end of JSON input while parsing near ‘…ze”:”0.4.0″},”devDepe’的解决方法

参考链接:https://github.com/npm/npm/issues/19072

错误描述:NPM安装依赖包时报错,Unexpected end of JSON input while parsing near ‘…ze”:”0.4.0″},”devDepe’

解决办法:npm cache clean –force

tip:transform:translate(-50%, -50%)造成文字模糊的解决方案

原因:transform的元素的宽度和高度并不是偶数,移动了50%之后,像素点并不是整数,此时出现了小数,和显示像素不对应。

解决方案:1.增加或减少1个像素点即可(猜测这也是为什么移动端设计稿标注图需要按照iPhone6的750或者安卓的650来)

2.如果为了实现垂直居中,采用其他方法