asyncguo

Results 49 comments of asyncguo
trafficstars

1. ```js xhr.addEventListener('progress', function (e) { }, false) xhr.addEventListener('load', function (e) { }, false) xhr.addEventListener('error', function (e) { }, false) ``` 2. ```js [...files].filter(item => item.size { let xhr =...

```js 1. 遇到保留字符和#,encodeURIComponent会转义,而encodeURI不会。 2. Object.keys(object1).map(key => `${key}=${encodeURIComponent(object1[key])}`).join('&') 3. location.search 4. // zxx: 有bug decodeURIComponent(location.search).match(/([^?=&]+)=([^&]+)/g).reduce((obj, item) => { let [key, val] = item.split('=') obj[key] = val return obj },{}) 5. decodeURIComponent(location.search).match(/([^?=&]+)=([^&]+)/g).reduce((obj,...

[demo](https://codepen.io/asyncguo/pen/BaaXxjZ?editors=1100) ```css /* zxx: 选择器用得很溜~ */ .menu-list__row{ display: flex; flex-wrap: wrap; } .menu-list__row-item{ padding: 11% 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: #524840; color: #fff;...

1. ```js let _dialog = document.createElement('dialog') document.body.appendChild(_dialog) ``` 2. ```js _dialog.setAttribute('open', 'open') ``` 3. ```js let _button = document.createElement('button') _button.innerHTML = 'cancel' _dialog.appendChild(_button) _button.addEventListener('click', () => { _dialog.close() }) ```...

1. 利用localStorage ```js let randomFn = (arr = []) => { arr.sort(function () { return .5 - Math.random(); }); return arr } let uidSkinArr = localStorage.getItem('uidSkinArr') if (uidSkinArr) { uidSkinArr...

[demo](https://codepen.io/asyncguo/pen/pXRYJL) ```html 按钮 按钮 按钮 按钮 按钮 按钮 ``` ```css /* zxx: 下次请粘贴编译好的CSS */ .button-group{ display: flex; margin: 0 1rem 1rem 1rem; .button-item{ flex: 1; background-color: #fff; border: 1px solid...

1. 获取cookie ```js document.cookie ``` 2. 新增cookie ```js document.cookie = 'userid=1' ``` 3. 设置cookie过期时间 ```js time = new Date(time) time.setTime(time.getTime + (1 * 24 * 60 * 60 * 1000))...

```js 1. let textareaEl = document.querySelector('textarea') 2. textareaEl.setAttribute('rows', 5) 3. window.getComputedStyle(textareaEl).height 4. function setHeight(el) { let _lineHeight = window.getComputedStyle(el).lineHeight let _rows = el.getAttribute('rows') if (_lineHeight === 'normal') { let _fontSize...

[demo](https://codepen.io/asyncguo/pen/MWWjQZR?editors=1100) ```html Unwatch 63 Star 445 Fork 25 ``` ```css /* 链接颜色有问题,以及按钮组永远一行显示没能支持 */ ul{ margin: 0; padding: 0; } li{ list-style-type: none; } .button-group{ display: flex; font-size: 0; color: #24292e;...

[demo](https://codepen.io/asyncguo/pen/rNBqEox?editors=1100) ```css .tag-box{ display: inline-block; position: relative; width: 120px; height: 160px; overflow: hidden; color: white; font-size: 12px; } .tag{ position: absolute; left: 0; top: 0; background-color: #cd0000; } .tag.square{ padding:...