Skip to content

一些工作中写过的可能有用的代码片段 - 持续更新

Notifications You must be signed in to change notification settings

TerryBeanX2/myUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 

Repository files navigation

#一些工作中写过的可能有用的代码片段

  • 2017.8.22写了个格式化银行卡的方法
function formatBankcard(str){
    return str.split('').reduce((prev, next, index)=> {
        return prev + ((index % 4) ? next : (' ' + next ));
    });
}

let str = '6214143523234154320';
formatBankcard(str) //6214 1435 2323 4154 320
  • nginx跨域配置文件中的片段,极大提高前端开发效率,重点在于Access-Control-Allow-Headers 很难搜..已经解决
//允许自定义的header中带有下划线,我曾经被坑惨了..
underscores_in_headers  on;
//server中的代码段:
location / {	
    //设置了*还跨域失败多数是Header引起的,此处的值由需要填写,HEAD_INFO是自定义的东西
    add_header 'Access-Control-Allow-Headers' 'HEAD_INFO,Content-Type';
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET,POST';
    //保留参数(前提/apis)			
    #rewrite  ^.+apis/?(.*)$ /$1 break;
    include  uwsgi_params;	
    //代理地址			
    proxy_pass   http://[your link];
}

About

一些工作中写过的可能有用的代码片段 - 持续更新

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published