返回文章列表
react语法技巧
真值 && ......
true && "a" //输出 a
false && "a"
//输出 false
react-icons 各种图标库(包含ant-design等)
npm install react-icons --save
网址https://react-icons.github.io/react-icons/
reduce
reduce 函数的基本语法为:array.reduce(callbackfn, initialValue)。
callbackfn 是回调函数,它接受四个参数:前一个值(prev)、当前值(current)、当前索引(index)和数组本身(array)
initialValue 是初始值,可选参数。
let arr = [1, 2, 3, 4, 5]; let res = arr.reduce((prev, next) => prev + next) console.log(res); // 15