kaiyou

Results 76 issues of kaiyou

项目中碰到了个token失效的问题,明明有不停发心跳的.之前对token这个也是一知半解(虽然现在仍是),自己一点点看了项目中的代码才稍微清晰了一些.这次简单记录下 ## JSON Web Token >What's JSON Web Token? JSON Web Token (JWT, pronounced jot) is a relatively new token format used in space-constrained environments such as HTTP Authorization headers....

都是姿势
Node
项目中

使用webpack打包代码可以将各种类型的文件当做模块,即样式,图片都可以当做模块被require()进来,对于样式文件来说,好像是将样式文件通过相应的**loader**转化为字符串打包到js文件中,再由js生成style标签将样式放在style标签中插入到head标签中,这样做缺点是会使js文件体积变大 而通过[extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin)插件则可以将样式从js中抽出,生成单独的.css样式文件(根据entry入口),通过link标签引入.优缺点: > Advantages: > - Fewer style tags (older IE has a limit) > - CSS SourceMap (with devtool: "source-map" and css-loader?sourceMap) > - CSS requested in parallel >...

Vue
webpack
style 相关

> 对webpack认识不透彻,反反复复搞来搞去好多遍每次都有新体验,一是对webpack理解不深,二是过一段时间根本就忘光了,再看也只是有印象(就像让我现在再看ionic angular一样),所以打算有时间把用webpack的经验总结一下,每次都有豁然开朗,灵光一闪的地方,再回头看却那么陌生,一定是我当时注释写的不好,再就是没有整体做总结的锅。。。 ``` 开坑待填 ``` [一个参考](https://github.com/MeCKodo/webpack) [又一个参考](https://github.com/pigcan/blog/issues/5)

webpack

```javascript $('#myselect').select2({ data:dataArr,// 数据生成option placeholder:'请选择数据项', multiple:true,// 多选 closeOnSelect: false,// 选完是否收起 dropdownParent: $('.history-data-select-div') // dropdown位置相关 多选可能会有问题,会把框挡住 }); ``` 碰到了个 主要是清空option的问题 api提供了个 >The destroy method will remove the Select2 widget from the...

杂七杂八
项目中

* node获取url请求客户端ip(ABC三类地址外的则为外网)[https://www.zhihu.com/question/43517806](内网与外网) ```JavaScript //node获取url请求客户端ip const getClientIp = (req) => { let ip = req.headers['x-forwarded-for'] || req.ip || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress || ''; if(ip.split(',').length>0){ ip = ip.split(',')[0] } return...

Node
项目中

通过监听`visibilitychange`事件 可以用来切换title挺有意思的哈哈 ^ - ^ ```javascript var normal_title; document.addEventListener('visibilitychange',function(){ if(document.visibilityState=='hidden') { normal_title=document.title; document.title='TAT 不要离开我 (づ ̄ 3 ̄)づ'; $ }else document.title=normal_title; }); ``` ![changeTab](https://github.com/5Mi/markdown-images/blob/master/images/tabChange.gif?raw=true)

杂七杂八
都是姿势
html5

在js整数操作的时候,相当于去除小数点,parseInt。在正数的时候相当于Math.floor(),负数的时候相当于Math.ceil() ```javascript console.log(0.6|0)//0 console.log(1.1|0)//1 console.log(3.65555|0)//3 console.log(5.99999|0)//5 console.log(-7.777|0)//-7 ``` >好像`|0`就是用来去除小数点 [参考](http://www.haorooms.com/post/js_dsg_ysf)

杂七杂八
都是姿势
js

- 判断非空 ``` JavaScript /*判断非空*/ export function isEmpty(val) { if (val == null) return true; if (val == undefined || val == 'undefined') return true; if (val == "") return...

杂七杂八
js

``` javascript var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 gecko:...

都是姿势
js

原生构造函数是指语言内置的构造函数,通常用来生成数据结构。ECMAScript的原生构造函数大致有下面这些。 - Boolean() - Number() - String() - Array() - Date() - Function() - RegExp() - Error() - Object() 以前,这些原生构造函数是无法继承的,比如,不能自己定义一个Array的子类。 ``` javascript function FakeArray(){ Array.apply(this,arguments); } FakeArray.prototype = []; FakeArray.prototype.constructor...

ES6
都是姿势
js