深圳程序员开发群test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "printWidth": 80, | |
| "semi": true, | |
| "singleQuote": true, | |
| "tabWidth": 2, | |
| "trailingComma": "none", | |
| "arrowParens": "avoid" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Define a property. | |
| */ | |
| function def (obj, key, val, enumerable) { | |
| Object.defineProperty(obj, key, { | |
| value: val, | |
| enumerable: !!enumerable, | |
| writable: true, | |
| configurable: true | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*使用伪类 + transform*/ | |
| .border_bottom { | |
| overflow: hidden; | |
| position: relative; | |
| border: none!important; | |
| } | |
| .border_bottom:after { | |
| content: "."; | |
| position: absolute; | |
| left: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 获取 url 的查询参数,转为 object | |
| const decodeURI = (url = window.location.search) => { | |
| return url.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v) | |
| } | |
| // 1. 判断两个对象是否严格相等,保证isEqual(NaN, NaN)返回true。 | |
| // 2. 与Object.is 的区别在于对+0和-0的比较 | |
| function isEqual(a, b) { | |
| return (a === b || (a !== a && b !== b)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const hasClass = function(obj, cls) { | |
| return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); | |
| }; | |
| export const addClass = function(obj, cls) { | |
| if (!hasClass(obj, cls)) obj.className += ' ' + cls; | |
| }; | |
| export const removeClass = function(obj, cls) { | |
| if (hasClass(obj, cls)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function time(time = +new Date()) { | |
| var date = new Date(time + 8 * 3600 * 1000); | |
| return date.toJSON().substr(0, 19).replace('T', ' '); | |
| } | |
| time(); // "2019-04-18 16:20:22" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var search = location.search.substring(1); | |
| JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ajax = (options = {}) => { | |
| options.method = (options.method || "GET").toUpperCase() | |
| options.dataType = options.dataType || 'json' | |
| options.async = options.async || true | |
| let xhr = null | |
| if (window.XMLHttpRequest) { | |
| xhr = new XMLHttpRequest() | |
| } else { | |
| xhr = new ActiveXObject('Microsoft.XMLHTTP') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //获取指定form中的所有的<input>对象 | |
| function getElements(formId) { | |
| var form = document.getElementById(formId); | |
| var elements = new Array(); | |
| var tagElements = form.getElementsByTagName('input'); | |
| for (var j = 0; j < tagElements.length; j++){ | |
| elements.push(tagElements[j]); | |
| } | |
| return elements; |