会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
吴小明
博客园
首页
新随笔
联系
订阅
管理
1
2
3
4
5
···
63
下一页
2022年7月13日
position: fixed;在ios上滑动有问题
摘要: 解决办法一: transform: translateZ(0); -webkit-transform: translateZ(0); 解释:在使用position:fixed的元素上加上该属性。 解决办法二: 用上下布局排版,可以用calc去计算,也可以用flex布局
阅读全文
posted @ 2022-07-13 18:01 吴小明-
阅读(280)
评论(0)
推荐(0)
2022年6月4日
throw error 和 throw new Error() 的区别
摘要: 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 吴小明-
阅读(153)
评论(0)
推荐(0)
2022年5月23日
基于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 吴小明-
阅读(792)
评论(0)
推荐(0)
2022年5月22日
为什么不建议用for in遍历数组
摘要: 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 吴小明-
阅读(375)
评论(0)
推荐(0)
2022年4月27日
js判断一个数组是否包含另一个数组
摘要: 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 吴小明-
阅读(2187)
评论(0)
推荐(0)
2022年4月26日
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 吴小明-
阅读(373)
评论(0)
推荐(0)
2022年4月25日
JS合并数组中id相同的项目 去重合并
摘要: 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 吴小明-
阅读(818)
评论(0)
推荐(0)
2022年4月7日
ES5数组的reduce方法
摘要: 一、reduce方法接收2个参数 参数1:function(accumulator, currentValue, index, arr) {},必须 accumulator:必须,初始值(initialValue)或计算后的返回值(上次调用函数的返回值) currentValue:必须,当前元素 i
阅读全文
posted @ 2022-04-07 16:47 吴小明-
阅读(161)
评论(0)
推荐(0)
2022年4月6日
compositionstart和compositionend事件
摘要: 使用场景: input事件没办法知道我们在使用中文输入法,所以当我们在输入框中编辑中文的时候,按下字母的那一刻就开始触发input事件。 使用compositionstart和compositionend可以对此情况进行优化 需求: 根据用户输入的文字过滤列表选项 实现: <template> <d
阅读全文
posted @ 2022-04-06 17:08 吴小明-
阅读(573)
评论(0)
推荐(0)
vue点击按钮重复提交(思路:通过指令的方式解决)
摘要: 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 吴小明-
阅读(389)
评论(0)
推荐(0)
1
2
3
4
5
···
63
下一页
公告