From aa9ba8b7d35c7c62ce2fca9f447ecfa3565b2439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=99=93=E7=90=B3?= <2115152499@qq.com> Date: Fri, 15 Dec 2023 11:40:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20231215 \344\275\234\344\270\232.md" | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "29 \346\262\210\346\231\223\347\220\263/20231215 \344\275\234\344\270\232.md" diff --git "a/29 \346\262\210\346\231\223\347\220\263/20231215 \344\275\234\344\270\232.md" "b/29 \346\262\210\346\231\223\347\220\263/20231215 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..1d48087 --- /dev/null +++ "b/29 \346\262\210\346\231\223\347\220\263/20231215 \344\275\234\344\270\232.md" @@ -0,0 +1,60 @@ +## 笔记 + +```js + + +//数组解构 +const [a, b, c] = [1, 2, 3] +console.log(a) //1 +console.log(b) //2 +console.log(c) //3 +//解构嵌套对象 +const obj = { + a:1, + b:2, + c:{ + d:3, + e:4 + } +} +// 方法1: +const {a, b, {d, e}} = obj + +// 方法2: +const {a, b, c} = obj +const {d, e} = c //对c这个对象再进行一步解构 + +//可扩展运算符 +const obj = { a:1, b:2, c:3, d:{e:4} } +const {a, b, ...rest} = obj // 意思是a, b解构出来,obj剩余参数则收拢在一起 +//只不过此时收拢后的结果不是数组,而是收拢在一起成为对象 +console.log(rest) //{c:3, d:{e:4}} +//拷贝 +const arr = [1, 2, 3] +const newArr = [...arr] +newArr.push(100) + +console.log(arr) // [1, 2, 3] +console.log(newArr) // [1, 2, 3, 100] + +/* + jquery事件: + 1.没有on,直接以js事件去掉相应的on即可 + 2.位置:ready()内 + ready(function){ + $("jquery选择器").事件类型(function(){ + 事件体... + }) + } + */ + $(document).ready(function(){ //可缩写为 $(function{}) + // 鼠标单击事件 + $("#myButton").click(function(){ + $("#myText").css("background-color","red"); + }) + })// ready()结束标记 +获得属性 $('').attr('属性名','属性值') + attr({"属性名":"属性值","属性名":"属性值","属性名":"属性值"}):设置多个属性值 + +``` + -- Gitee From 6588199c6778d15062b1d3c5cb04543888d14e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=99=93=E7=90=B3?= <2115152499@qq.com> Date: Sun, 17 Dec 2023 22:41:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20231217 \344\275\234\344\270\232.md" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "29 \346\262\210\346\231\223\347\220\263/20231217 \344\275\234\344\270\232.md" diff --git "a/29 \346\262\210\346\231\223\347\220\263/20231217 \344\275\234\344\270\232.md" "b/29 \346\262\210\346\231\223\347\220\263/20231217 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..87ac027 --- /dev/null +++ "b/29 \346\262\210\346\231\223\347\220\263/20231217 \344\275\234\344\270\232.md" @@ -0,0 +1,42 @@ +```js +//调用axios参数,参数是一个对象,这个对象包括url属性,表示要调用的数据服务器的网址,结果会在then()里返回,()里的参数是回调函数 +axios({ + url: 'http://hmajax.itheima.net/api/register', + // 指定请求方法 + method: 'post', //提交数据到服务器 + data: { + 参数名:值 //当属姓名和vlaue位置变量名同名可简写 + } + }).then(result => { + console.log(result) + }).catch(error => { + // 捕获请求响应的错误并做后续处理 + // console.log(error) + console.log(error.response.data.message) + // alert(error.response.data.message) + }) + }) +``` + +```html +$.ajax方法使用规范 + + + + + + +``` + -- Gitee