随笔分类 - js
摘要:let obj = { data: { data: { cites: [1, 2, 3], }, }, }; let { data: { data: res }, } = obj; // 结构出来 res = cites: [1, 2, 3]
阅读全文
摘要:1. 判断对象有没有这条属性 hasOwnProperty let obj = { a:1, b:2 } console.log(obj.hasOwnProperty("c")); //false console.log(obj.hasOwnProperty("a")); //true 2.对象删除
阅读全文
摘要:<script> import {query} from '@/api/index' export default { data() { return {}; }, created() { this.Init() }, methods: { async Init() { const res = aw
阅读全文
摘要:1. Date.now() H5新增的获取总的毫秒数(时间戳) 2.倒计时 function countDown(time) { let nowTime = Date.now(); //获取当前时间戳 let inputTime = +new Date(time); //获取用户输入的时间戳 let
阅读全文
摘要:链接 https://blog.csdn.net/jiang7701037/article/details/98738487 let p = { id: "001", name: "刘德华", wife: { id: "008", name: "刘德华的妻子", address: { city: "
阅读全文
摘要:export function getNowTime() { let now = new Date() let year = now.getFullYear() let month = now.getMonth() + 1 let day = now.getDate() let hour = now
阅读全文
摘要:let arr = [1,1,"1","1",true,true,"true",{},{},"{}",null,null,undefined,undefined] 1. // 方法1 let uniqueOne = Array.from(new Set(arr)) //Array.from() 类数
阅读全文
摘要:1.字符串截取 substring() //包含开始 不包含结束 (返回新字符串,不改变原字符串) let str = "123456"; console.log( str .substring(1,3) ); //23 console.log( str .substring(1, 100) );
阅读全文
摘要:1.数组末尾追加 push let arr = [12,34,26]; arr.push(100); //返回一个新的长度 arr.length=4console.log(arr)//结果为 [12,34,26,100] 2.数组末尾删除 pop let arr = [108,112,39,10];
阅读全文
摘要:function getUUID() { function S4() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); } return (S4() + S4() + "-" + S4() + "-"
阅读全文