Skip to content

Instantly share code, notes, and snippets.

View lilywang711's full-sized avatar
🎯
working

lily wang lilywang711

🎯
working
View GitHub Profile
@lilywang711
lilywang711 / prettier-config.json
Created July 5, 2020 07:30
我的 prettier 配置
{
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"arrowParens": "avoid"
}
@lilywang711
lilywang711 / util-functions.js
Last active December 13, 2019 07:00
util functions in vue/packages/vue-template-compiler/build.js
/**
* Define a property.
*/
function def (obj, key, val, enumerable) {
Object.defineProperty(obj, key, {
value: val,
enumerable: !!enumerable,
writable: true,
configurable: true
});
/*使用伪类 + transform*/
.border_bottom {
overflow: hidden;
position: relative;
border: none!important;
}
.border_bottom:after {
content: ".";
position: absolute;
left: 0;
// 获取 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));
}
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)) {
@lilywang711
lilywang711 / formatDate.js
Created April 18, 2019 08:20
格式化日期
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"
var search = location.search.substring(1);
JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}')
@lilywang711
lilywang711 / groupTest.md
Created December 28, 2018 09:23
深圳程序员开发群test

深圳程序员开发群test

@lilywang711
lilywang711 / ajax.js
Last active November 27, 2018 14:35
ajax.js
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')
}
//获取指定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;