摘要: 解决办法一: transform: translateZ(0); -webkit-transform: translateZ(0); 解释:在使用position:fixed的元素上加上该属性。 解决办法二: 用上下布局排版,可以用calc去计算,也可以用flex布局 阅读全文
posted @ 2022-07-13 18:01 吴小明- 阅读(237) 评论(0) 推荐(0) 编辑
摘要: const num = 5 try { if (num 5) { throw new Error('num不能为5') } } catch (e) { console.log(e) // 打印出Error对象:Error: num不能为5 console.log(e.message) // 打印:n 阅读全文
posted @ 2022-06-04 22:12 吴小明- 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 基于vant的radio组件封装自己的级联组件 <template> <div class="demo"> <div class="top"> <ul> <li @click="one">回到顶级</li> <li v-for="item of parents" :key="item.value" @click="jump(item)">{{it 阅读全文
posted @ 2022-05-23 09:06 吴小明- 阅读(688) 评论(0) 推荐(0) 编辑
摘要: for...in本身是Object的遍历方法,js中的数组也继承自Object,所以也能够使用for...in遍历出属性。然而for...in遍历数组时有一些细节需要注意。 1、for...in遍历的属性是字符串,而不是数字 const arr = [1, 2, 3] for (const i in 阅读全文
posted @ 2022-05-22 18:30 吴小明- 阅读(309) 评论(0) 推荐(0) 编辑
摘要: const a = [1, 2, 3, 4, 5, 6, 7, 8] const b = [5, 5, 1, 2] const c = [3, 9] // 判断arr1是否包含arr2 const isInclude = (arr1, arr2) => arr2.every((val) => arr 阅读全文
posted @ 2022-04-27 10:47 吴小明- 阅读(1822) 评论(0) 推荐(0) 编辑
摘要: react自定义hooks解决内存泄漏 销毁组件时,报警告: 解决: utils/hooks.ts export const useFetchState = (...props: any) => { const focus = useRef<any>(null); const [state, setState] = useState(.. 阅读全文
posted @ 2022-04-26 11:17 吴小明- 阅读(293) 评论(0) 推荐(0) 编辑
摘要: function mergePropertyById(arr, property) { const tempIds = [], newArr = [] for (const item of arr) { if (!tempIds.includes(item.id)) { const obj = { 阅读全文
posted @ 2022-04-25 20:43 吴小明- 阅读(753) 评论(0) 推荐(0) 编辑
摘要: 一、reduce方法接收2个参数 参数1:function(accumulator, currentValue, index, arr) {},必须 accumulator:必须,初始值(initialValue)或计算后的返回值(上次调用函数的返回值) currentValue:必须,当前元素 i 阅读全文
posted @ 2022-04-07 16:47 吴小明- 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 使用场景: input事件没办法知道我们在使用中文输入法,所以当我们在输入框中编辑中文的时候,按下字母的那一刻就开始触发input事件。 使用compositionstart和compositionend可以对此情况进行优化 需求: 根据用户输入的文字过滤列表选项 实现: <template> <d 阅读全文
posted @ 2022-04-06 17:08 吴小明- 阅读(457) 评论(0) 推荐(0) 编辑
摘要: 1、src/directives/preventClick.js import Vue from 'vue' Vue.directive('preventClick', { inserted(el) { el.addEventListener('click', () => { if (!el.dis 阅读全文
posted @ 2022-04-06 16:35 吴小明- 阅读(326) 评论(0) 推荐(0) 编辑