随笔分类 -  javascript

摘要:根据浏览器窗口大小变化进行自适应,使用 window.onresize = ()=>myChart.resize() 浏览器窗口不变,容器大小变化(例如:侧边菜单栏收缩),vue3为例 let myChart = null; onMounted(() => { setTimeout(() => { 阅读全文
posted @ 2023-10-08 14:46 helloSWZ 阅读(626) 评论(0) 推荐(0) 编辑
摘要:###加法 ``` function accAdd(num1,num2){ var r1,r2,m; try{r1=num1.toString().split(".")[1].length}catch(e){r1=0} try{r2=num2.toString().split(".")[1].len 阅读全文
posted @ 2023-06-21 08:39 helloSWZ 阅读(427) 评论(0) 推荐(0) 编辑
摘要:###同源: 两个页面拥有相同的协议,端口,域名 就是同源,如果有一个不相同就是不同源。 ###jsonp ####请求 // 1.封装一个jsonp函数; jsonp({ // method: 'GET',// 所有的jsonp请求都是get请求,所以这个属性可以不写了 // data: , // 阅读全文
posted @ 2022-09-07 14:58 helloSWZ 阅读(66) 评论(0) 推荐(0) 编辑
摘要:###页面加载: 向浏览器输入网址 浏览器根据 DNS 服务器得到域名的 IP 地址 向这个 IP 的机器发送 HTTP 请求 服务器收到、处理并返回 HTTP 请求 浏览器接收到服务器返回的内容 ###页面渲染: 解析HTML,生成DOM树,解析CSS,生成CSSOM树 将DOM树和CSSOM树结 阅读全文
posted @ 2022-07-28 14:49 helloSWZ 阅读(81) 评论(0) 推荐(0) 编辑
摘要://designWidth:设计稿的实际宽度值,需要根据实际设置 //maxWidth:制作稿的最大宽度值,需要根据实际设置 //这段js的最后面有两个参数记得要设置,一个为设计稿实际宽度,一个为制作稿最大宽度,例如设计稿为750,最大宽度为750,则为(750,750) (function(des 阅读全文
posted @ 2021-12-27 16:48 helloSWZ 阅读(217) 评论(0) 推荐(0) 编辑
摘要:##attr()和prop()有何区别? 使用prop的时候,返回值是标准属性,true/false,比如$('#checkbox').prop('disabled'),不会返回“disabled”或者“”,只会是true/false。当然赋值的时候也是如此。使用attr,如disabled='di 阅读全文
posted @ 2021-11-19 10:49 helloSWZ 阅读(239) 评论(0) 推荐(0) 编辑
摘要:找到layui目录下table.js d.exportFile = function (e, t, i) { t = t || d.clearCacheKey(d.cache[e]), i = i || "csv"; var a = c.config[e] || {}, l = {csv: "tex 阅读全文
posted @ 2021-10-28 21:15 helloSWZ 阅读(323) 评论(0) 推荐(0) 编辑
摘要:function submoney(value){ var b = false; if (value == null || value == "") return "0"; value = value.toString(); if(value.indexOf('-') != -1){ b= true 阅读全文
posted @ 2021-07-30 15:49 helloSWZ 阅读(467) 评论(0) 推荐(0) 编辑
摘要:var now = new Date();var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate() 阅读全文
posted @ 2021-07-30 15:47 helloSWZ 阅读(1324) 评论(0) 推荐(0) 编辑
摘要:1.jQuery ajax $.ajax({ type: 'POST', url: url, data: data, dataType: dataType, success: function () {}, error: function () {} }); 传统 Ajax 指的是 XMLHttpR 阅读全文
posted @ 2021-01-22 15:36 helloSWZ 阅读(128) 评论(0) 推荐(0) 编辑
摘要:###浅拷贝 //用=赋值 var a = {name:'hello'}; var b = a; b.name="world"; console.log(a.name); // 只复制第一层的浅拷贝 function simpleCopy(obj1) { var obj2 = Array.isArr 阅读全文
posted @ 2021-01-14 17:53 helloSWZ 阅读(138) 评论(0) 推荐(0) 编辑
摘要:###1.编写方式 let xx = item ⇒item 单条语句可以省略return和{},单个参数可以省略() ###2.箭头函数不能作为构造函数 let A=()=>{}; let a = new A();报错 function A(){}; let a = new A();不报错 ###3 阅读全文
posted @ 2021-01-11 15:43 helloSWZ 阅读(120) 评论(0) 推荐(0) 编辑
摘要:###同源策略 协议+域名+端口 相同 ###解决方案 1.jsonp解决跨域 2.nginx代理 3.中间件proxy 4.WebSocket 5.PostMessage 6.CORS 服务端设置Access-Control-Allow-Origin,若需要带cookie,前后端都需要设置 阅读全文
posted @ 2021-01-04 17:15 helloSWZ 阅读(130) 评论(0) 推荐(0) 编辑
摘要:###判断括号是否有效 var isValid = function(s) { let map = new Map(); let map1 = new Map(); map.set("(",")"); map.set("[","]"); map.set("{","}"); map1.set(")", 阅读全文
posted @ 2020-12-24 17:56 helloSWZ 阅读(287) 评论(0) 推荐(0) 编辑
摘要:##filter()去重 [1,2,3,4,3,2,1].filter((item,index,arr)=>arr.indexOf(item) index) ##new Set()去重 let arr = [...new Set([1,2,3,4,3,2,1])] ##reduce()去重 let 阅读全文
posted @ 2020-12-24 09:59 helloSWZ 阅读(101) 评论(0) 推荐(0) 编辑
摘要:##Math 1.Math.abs() 获取绝对值; 2.Math.round() 四舍五入; 3.Math.random() 0~1随机小数; 4.Math.ceil() Math.floor() 向上取整和向下取整; 5.Math.max() Math.min() 最大最小值; 6.Math.P 阅读全文
posted @ 2020-12-23 14:46 helloSWZ 阅读(134) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示