Forx-Js

Results 9 comments of Forx-Js

```javascript function arrayFlat(list = []) { return [...new Set(function (arr) { //去重 const newArr = Array.prototype.concat.apply([], arr) //扁平化 return newArr.some(Array.isArray) ? arguments.callee(newArr) : newArr; //递归 }(list))] .sort((a, b) =>a -...

```js const arr = Array.from({ length: 10 }, () => ~~(Math.random() * 50)) //创建数据 .sort((a, b) => a - b), //排序 arr1 = [...new Set(arr.map(i => ~~(i / 10)))] //划分区域...

在线[DEMO](https://codepen.io/forx-js/pen/oKgjPp) > 感谢 @XboxYan 提供的浮动在前的思路 兼容IE8... 好吧,读书人的事... ```html 都市连载中54.82万字 这次是一个新的故事这次是一个新的故事这次是一个新的故事 科幻154.82万字 这次是一个新的故事这次是一个新的故事 爱情完结154.82万字 这次是一个新的故事这次是一个新的故事这次是一个新的故事 科幻4.82万字 对应的CSS代码,注意缩进和代码高亮 科幻连载中4.82万字 这次是一个新的故事 ``` ```css .list { padding: 0; list-style: none; } .item { margin:...

1. 获取form ```js const formDom = document.getElementById('loginForm'); ``` 2. 阻止默认 ```js formDom.addEventListener('submit', e=>{ e.preventDefault(); } ``` 3. 获取数据 ```js const getForm2Object = (formDom) => { const formData = new FormData(formDom),...

> [DEMO](https://codepen.io/forx-js/pen/PMRdaN?editors=0010) > 还是使用了点js,就为了切换开关的动效 ```html 布局 Flex布局 Grid布局 Shapes布局 Columns布局 组件 按钮 输入框 下拉列表 单复选框 ``` > 使用的css里的target 切换的点击 > 上箭头和下箭头用的是label的两个伪元素,得到了有点奇怪的动效, 其实就是为了实验效果(之前从未写过) ```css ul { margin: 0; list-style: none; padding:...

1. 使用`onreadystatechange` `readyState === 4` 来判断完成,使用`statusText==='OK'`判断是否成功 ```js xhr.onreadystatechange = ({ currentTarget, currentTarget: { readyState, response, statusText } }) => { if (readyState === 4) { if (statusText.toLocaleLowerCase() === 'ok') {...

\> [点击这里](https://codepen.io/forx-js/pen/agVdvG?editors=1100) \< ```css .main { background-color: #f5f5f5; padding: 16px; } .row { border: 1px solid black; // 显示父子之间的宽度关系 display: flex; flex-basis: row nowrap; justify-content: space-around; } .col { flex:...

```js /** * * @param {string} title * @returns {string} */ const clipString = title => { const titleArray = [...title], // 将字符串转成数组,主要应对后续emoji长度问题 length = titleArray.length, // 获取字符串长度 maxLength =...

A PEN BY [Forx-Js](https://codepen.io/forx-js/pen/NVVYmG?editors=1100) 适当的加了加`pading`和`background` ```css .container{ position:absolute; top:0; left:0; right:0; bottom:0; display:flex; flex-flow:column nowrap; } .content{ flex:1 0; } .footer{ flex:0 0; background:#333; padding:8px 12px; color:#fff } ```