摘要: 1 let a = [1, 2, 3, 4, 5]; 2 let arr = a.splice(2, 1); // 剩余数组 3 let content = arr[0]; // 目标元素 4 5 console.log('初始化', a) 6 console.log('剩余数组 ', arr) 7 阅读全文
posted @ 2020-09-23 17:22 无人问及 阅读(873) 评论(0) 推荐(0) 编辑
摘要: 对象去重 对象样式:{ {}, {} } 1 // 对象去重 2 export const delRepeat = (data) => { 3 let keys = Object.keys(data); 4 let set = new Set(); 5 let arrs = []; 6 keys.f 阅读全文
posted @ 2020-07-31 14:18 无人问及 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 1 三元运算符 1 const MyComponent = ({ name }) => ( 2 3 <div className="hello"> 4 5 {name ? `Hello ${name}` : 'Please sign in'} 6 7 </div> 8 9 ); 有几点需要注意。因为 阅读全文
posted @ 2020-06-18 21:36 无人问及 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 先看看 react blog, 看官方怎么说的In React blog post: URLs starting with javascript: are a dangerous attack surface because it’s easy to accidentally include uns 阅读全文
posted @ 2020-03-30 14:25 无人问及 阅读(7597) 评论(1) 推荐(0) 编辑
摘要: 获取当前时间 let now = new Date(); 获取三天前时间 let threeNow = new Date(now.getTime() - 24*60*60*1000*3); 时间格式化 let nowStr = now.format("yyyy-MM-dd hh:mm:ss"); l 阅读全文
posted @ 2020-03-24 11:31 无人问及 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Date.prototype.format = function (fmt) { if (Number.isNaN(this.getMonth()) || Number.isNaN(this.getDate()) || Number.isNaN(this.getHours())) return '' 阅读全文
posted @ 2020-03-24 11:24 无人问及 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 getAll(id){ 2 axios.defaults.withCredentials=true; 3 axios.get(`$请求地址}`) 4 .then(result => { 5 console.info( result ); 6 }).catch(error => { 7 conso 阅读全文
posted @ 2020-03-23 20:57 无人问及 阅读(6991) 评论(0) 推荐(0) 编辑
摘要: 1 if判断,满足条件才渲染 1 if(x < 2) return <div>页面</div> 2 return null ; 2 三元运算符 1 return ( 2 <div> 3 { x <2 4 ? <ItemEdit item={item} /> 5 : <ItemView item={i 阅读全文
posted @ 2020-03-23 09:40 无人问及 阅读(118) 评论(0) 推荐(0) 编辑
摘要: react 引入站内图片的两种方式 : 1、通过import 引入图片 import yesPic from "../assets/images/yes.png"; import noPic from "../assets/images/no.png"; 使用:<img src={yesPic} a 阅读全文
posted @ 2019-11-25 11:11 无人问及 阅读(3483) 评论(0) 推荐(0) 编辑
摘要: 允许网页宽度自动调整 在head标签里加入viewport元标签,viewport是网页默认宽度和高度 //网页宽=屏幕宽,原始缩放比0.5 <meta name="viewport" content="width=device-width, initial-scale=0.5" /> 不要固定宽度 阅读全文
posted @ 2019-10-26 19:37 无人问及 阅读(195) 评论(0) 推荐(0) 编辑