加载中...

摘要: 1、jquery通过script标签直接引入 2、$(document).ready(functioin(){ }) 3、jquery对象与DOM对象互换 jquery->DOM转换:var \(box1=\)("#box1"); var box1=$box1[0]或者var box1=$box1. 阅读全文
posted @ 2021-12-01 17:17 莫等闲O(∩_∩)O~~ 阅读(29) 评论(0) 推荐(0)
摘要: 1、简单形式 ①JSON中没有undefined值 ②JSON中的字符串必须使用双引号 ③JSON是不能注释的 2、对象形式 JSON的对象形式对应着JS中的对象 { "name":"jiang", "age":18 } 注意:只要和字符串有关的双引号 不支持undefined 3、数组形式 阅读全文
posted @ 2021-11-02 17:21 莫等闲O(∩_∩)O~~ 阅读(80) 评论(0) 推荐(0)
摘要: 1、创建xhr对象 const xht=new XMLHttpRequest(); 2、监听事件,处理响应(当获取到响应后,会触发xhr的readystatechange事件) xhr.onreadystatechange=()=>{ if(xhr.readyState! == 4) return; 阅读全文
posted @ 2021-11-01 14:38 莫等闲O(∩_∩)O~~ 阅读(83) 评论(0) 推荐(0)
摘要: 1、Promise是异步操作的解决方案 const p=new Promise((resolve,reject)=>{ resolve();//成功 reject();//失败 }) // promise的状态一旦变化,就不会再改变了 2、then方法 p.then( ()=>{ } ()=>{ } 阅读全文
posted @ 2021-10-28 18:11 莫等闲O(∩_∩)O~~ 阅读(27) 评论(0) 推荐(0)
摘要: 1、模拟私有属性和方法 以_开头的变量设为私有数据 将私有属性和方法移除类 阅读全文
posted @ 2021-10-28 17:32 莫等闲O(∩_∩)O~~ 阅读(32) 评论(0) 推荐(0)
摘要: 1、class声明:class Person{ constructor() } 2、实例化时执行构造方法 class Person{ constructor(name,age){ this.name='name', this.age=age, } speaker(){} //添加方法,各实例共享 } 阅读全文
posted @ 2021-10-28 17:14 莫等闲O(∩_∩)O~~ 阅读(363) 评论(0) 推荐(0)
摘要: 1、可以通过Array.from转换为数组 console.log(Array.from('str')); 2、可转换为数组:所有可遍历的 字符串、Set、Map、Nodelist、arguments 3、 阅读全文
posted @ 2021-10-27 19:44 莫等闲O(∩_∩)O~~ 阅读(96) 评论(0) 推荐(0)
摘要: 1、去掉首尾空格 console.log(' adc'.trimStart()) //adc,trimStart可以写成trimLeft 阅读全文
posted @ 2021-10-27 11:26 莫等闲O(∩_∩)O~~ 阅读(46) 评论(0) 推荐(0)
摘要: 1、用于补全字符串 console.log('x'.padstart(3,'ad')); //adx ,字符串总长度为3,字符串开头添加ad console.log('x'.padstart(4,'ad')); //adax console.log('x'.padend(5,'ad')); //xa 阅读全文
posted @ 2021-10-27 11:11 莫等闲O(∩_∩)O~~ 阅读(62) 评论(0) 推荐(0)
摘要: 1、判断字符串中是否存在指定字符 console.log('abc'.includes(a,0)) //true,从索引值0开始看是否存在a console.log('abc'.includes(a,1)) //false console.log('abc'.includes(ab,0)) //tr 阅读全文
posted @ 2021-10-26 17:00 莫等闲O(∩_∩)O~~ 阅读(125) 评论(0) 推荐(0)