摘要: MyButton.vue: <template> <button :class="['my-btn',btnClass]"> <slot name='btnText'></slot> </button> </template> <script> export default { props: { b 阅读全文
posted @ 2021-08-05 21:35 吴小明- 阅读(314) 评论(0) 推荐(0) 编辑
摘要: <template> <div id="app"> <h1>axios拦截器</h1> <button @click="handleClick">按钮</button> <p>{{title}}</p> <div v-if="loading">loading...</div> </div> </te 阅读全文
posted @ 2021-08-05 21:17 吴小明- 阅读(75) 评论(0) 推荐(0) 编辑
摘要: <li v-for="(item,index) in list" :key="index" class="common" :class="index currentIndex?'active':''">{{item}}</li> <li v-for="(item,index) in list" :k 阅读全文
posted @ 2021-08-05 21:02 吴小明- 阅读(524) 评论(0) 推荐(0) 编辑
摘要: [].forEach.call($$("*"),function(a){ a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) }) 阅读全文
posted @ 2021-08-05 17:54 吴小明- 阅读(34) 评论(0) 推荐(0) 编辑
摘要: function star(rate){ const star='★★★★★☆☆☆☆☆' return star.slice(5-rate,10-rate) } 阅读全文
posted @ 2021-08-05 17:50 吴小明- 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 扩展运算符的剩余参数,如果想删除对象中的某个属性,这是一个思路 可以对原对象中的字段重新赋值,以及添加一个新的字段 const obj = { name: 'xx', age: 12 } const o = { ...obj, name: 'yy', hobby: 'ss' } // 重写name, 阅读全文
posted @ 2021-08-05 17:11 吴小明- 阅读(947) 评论(0) 推荐(0) 编辑
摘要: 利用对象对数组的每一项进行解构,可以方便地获取数组的第n个值 阅读全文
posted @ 2021-08-05 16:39 吴小明- 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑