随笔分类 - js
摘要:1.首先需要定义跳转的位置 <div id="anchorID"></div> 2.直接使用如下方式即可 document.getElementById('anchorID').scrollIntoView({ behavior:"smooth" })
阅读全文
摘要:1.方式一 document.getElementById("app").style.width 2.方式二: const el = document.getElementById('app') console.log(window.getComputedStyle(el).width)
阅读全文
摘要:1.页面中点击按钮需要新建轮播(需要新建多个),出现顺序错乱的问题 当页面中通过点击按钮切换轮播,即点击按钮需要new swiper,新建后,页面中swiper内容没有问题 但是,点击上一个下一个按钮,顺序会发生错乱 在new 之前需要使用destroy销毁 2.使用loop为true时,当数据量为
阅读全文
摘要:使用海康自带的插件 东西放在了百度网盘 可以先使用这个例子先调试, 只需要更改
阅读全文
摘要:后端返回的文件流格式 前端解决 axios({ url:"/api/Component/ins/downloadQr?codes=" + data.codeIdentification, method:"GET", headers:{ "Authorization": window.platToke
阅读全文
摘要:方式一: document.getElementById('componentQRcode').src = "https://api.qrserver.com/v1/create-qr-code?data=" + ”需要生成的内容“ 方式二: <!DOCTYPE html> <html lang="
阅读全文
摘要:let data = [{ id: 2, time: '2019-04-26 10:53:19' }, { id: 4, time: '2019-04-26 10:51:19' }, { id: 1, time: '2019-04-26 11:04:32' }, { id: 3, time: '20
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi
阅读全文
摘要:let arr = [] for (let i = 0; i < menuList.length; i++) { var arr2 = [] for (let j = 0; j < menuList[i].chileMenuList.length; j++) { arr2[j] = menuList
阅读全文
摘要:1.使用set map 实现 let arr = [{ "name" : "张三", "id" : 1 },{ "name" : "李四", "id" : 3 },{ "name" : "张三", "id" : 2 }]; let names = arr.map(item => item["name
阅读全文
摘要:1.将文件放在public中(一定要放在public中) 2.a标签书写 <a href="登记模板.xls" download="登记模板.xls">下载Excel模板</a> (其中download属性控制下载后文件的名称)
阅读全文
摘要:var url = 'http://127.0.0.1:8080//aaa/bbb' const a = document.createElement('a') //创建a标签 a.setAttribute('target','top') //href链接 a.setAttribute('href'
阅读全文
摘要:前端从后台获取token 并存储 localStorage.setItem('token', res.data.msg) 前端使用token var token = localStorage.getItem('token') 清空token window.localStorage.clear()
阅读全文
摘要:1.parseInt,parseFloat 大多数情况下不需要小数点后很多位,可以使用toFixed(n)方法修正后(n是小数后精确的位数)。 console.log(0.119*100); // 11.899999999999999 parseFloat((0.119*100).toFixed(1
阅读全文
摘要:document.getElementById('er').innerText
阅读全文
摘要:<script> var result = confirm("确定要这么做吗?"); if(result){//true alert('点了确定'); } else { //false alert('点了取消'); } </script>
阅读全文
摘要:1.如何遍历对象 for(let i in res.data.data) { console.log(i); console.log (res.data.data[i]) } Object.entries(res.data.data).forEach(o => { console.log(o[0])
阅读全文
摘要:let d = new Date(val)//生日val:1999-01-01 let t = d.getTime(d) // 转换为时间戳 var t1 = Date.parse(new Date());//获取当前时间戳 let t2 = t1 - t;//计算时间戳之差 t2 = t2 / 1
阅读全文
摘要:使用过滤器!!!!! this.project = this.project.filter(item => item.id !== project.id); 或者使用splice(需要遍历,很麻烦!!) 例如: for (let i = 0; i < element.project.length;
阅读全文
摘要:一个对象为: array:{ id:1, name:'zh' } 向对象中添加属性: this.array.sex = '男' 删除对象中的某个属性: delete this.array.sex
阅读全文