上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 63 下一页
摘要: const flatten = (arr, depth = 1) => depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), []) : arr.reduce((a, v) 阅读全文
posted @ 2021-08-05 16:21 吴小明- 阅读(59) 评论(0) 推荐(0) 编辑
摘要: var cars = ['BMW','Benz', 'Benz', 'Tesla', 'BMW', 'Toyota']; var carsObj = cars.reduce(function (obj, name) { obj[name] = obj[name] ? ++obj[name] : 1; 阅读全文
posted @ 2021-08-05 16:10 吴小明- 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 将数组中的值翻倍,再输入大于50的数: const numbers = [10, 20, 30, 40]; const doubledOver50 = numbers.reduce((finalList, num) => { num = num * 2; if (num > 50) { finalL 阅读全文
posted @ 2021-08-05 16:07 吴小明- 阅读(177) 评论(0) 推荐(0) 编辑
摘要: const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`) 阅读全文
posted @ 2021-08-05 15:59 吴小明- 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 适用于只需要执行一次的代码 阅读全文
posted @ 2021-08-05 15:28 吴小明- 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 1、方法一:定义临时变量 2、方法二:利用数组的解构(不需要第三个变量) 阅读全文
posted @ 2021-08-05 11:03 吴小明- 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 创建一个HelloWorld组件: <script> import Test from '@/components/Test' export default { props: { tag: String }, data() { return { arr: ['小王', '小明', '小红'] } } 阅读全文
posted @ 2021-08-02 17:46 吴小明- 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 1、通过改变父组件中的状态,从而改变兄弟组件的状态 Parent.vue: <template> <div> <h1>父组件</h1> <p>{{name}}</p> <Child1 :name='name' @child1Click='name = $event' /> <Child2 :name 阅读全文
posted @ 2021-08-02 16:38 吴小明- 阅读(813) 评论(0) 推荐(0) 编辑
摘要: 1、props+$emit Parent.vue: <template> <div> <h1>父组件</h1> <p>{{message}}</p> <Child :message='message' @messageChange='message=$event' /> </div> </templ 阅读全文
posted @ 2021-08-01 00:29 吴小明- 阅读(54) 评论(0) 推荐(0) 编辑
摘要: Safari浏览器不支持 white-space: nowrap; 使用时为了兼容 Safari 需要加上宽度限制 阅读全文
posted @ 2021-07-30 11:30 吴小明- 阅读(368) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 63 下一页