first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ajax_test</title>
</head>
<body>
<ul>
<li>
<div></div>
<img src="" alt="">
</li>
</ul>
</body>
<script>
var xhr = new XMLHttpRequest();
//通过GET请求
xhr.open("GET", "http://127.0.0.1:3000/api/json/index")
//发送请求
xhr.send()
xhr.onreadystatechange = () => {
//响应成功4,请求成功200
if (xhr.readyState == 4) {
if (xhr.status == 200) {
//data 字符串类型的对象或数组传
var data = JSON.parse(xhr.response)//从response中取数据
//数据存放在result 中
console.log(data.result.list);
//console.log(data.status);
//console.log(xhr.response);
data.result.list.forEach((v => {
document.querySelector("ul").innerHTML += `
<li>
<div class="title">${v.title}</div>
<img src="${v.img_src}" alt="">
</li>
`
}))
}
} else {
alert("当前网络不佳,请稍后重试!")
}
}
var a = {
id: 1,
name: "张三",
age: "18"
}
//转换成字符串
var c = JSON.stringify(a)
console.log(c);
// console.log(typeof a);//object
// console.log(a.name);
</script>
</html>

View File

@@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>this指向</title>
</head>
<body>
</body>
<script>
//function () {}
//创建类
// class swiper {
// time = 200
// text (){
// var time = 100;
// console.log("test :",this.time );
// }
// }
// var a = new swiper()
// a.text()
// console.log(a.time);
//创建对象
// var time = 400
// var a = {
// time : 200,
// test : () => {
// var time = 3000
// console.log(this.time);
// }
// }
// console.log(a.test());
// var pw=111
// function a(){
// var user = "123",pw=333
// console.log(this.pw)
// console.log(this);
// }
// a();
// var o = {
// user :"123"
// fn:function (){
// console.log(this.user);
// console.log(this);
// }
// }
// o.fn();
// var o = {
// a:10,
// b:{
// fn:function(){
// console.log(this.a);
// }
// },
// fn1:function(){
// console.log(this.a);
// }
// }
// o.fn1();
//选择最近的调用
// o.b.fn()
// function fn(){
// console.log(this);
// //this = fn()
// this.user = '123'
// return this;
// }
// var a = new fn;
// console.log(a.user);
// var o = {
// a: 10,
// b: {
// a: 12,
// fn: function () {
// console.log(this.a); //undefined
// console.log(this); //window
// }
// }
// }
// var j = o.b.fn;//没加()赋值给j,this调用时才指向具体函数
// j();//this指向windows
// var time = 4000
// var a = {
// time : 2000,
// b:function(){
// this.time = 5000;
// var test = () => {
// console.log(this.time);
// }
// return test
// }
// }
//箭头函数没有自己的this 内部的this值以外部非箭头函数的this
//没有function 不能使用new
// var ddd = new a.b()
// ddd()
//箭头函数 和 普通函数的区别
//如何改变this 指向?
var name = '小王',age = '17';
var obj = {
name : '小张',
objAge:this.age,
myFunction(){
console.log(this.name + "年龄"+this.age);
}
}
obj.objAge;
obj.myFunction()
</script>
</html>