init
This commit is contained in:
66
Html-Javascript/38-链式操作.html
Normal file
66
Html-Javascript/38-链式操作.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!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>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
|
||||
// function func() { // 正常 异常
|
||||
// return new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
// let data = { n: "想不到吧, 我三秒后才出现, 你们抓不到我的" }
|
||||
// if (Math.random() > 0.5) {
|
||||
// resolve(((data)));
|
||||
// } else {
|
||||
// reject("完蛋了, bbq");
|
||||
// }
|
||||
// }, 1000);
|
||||
// });
|
||||
// }
|
||||
|
||||
// // 链式操作
|
||||
// func().then().catch();
|
||||
|
||||
|
||||
// 函数
|
||||
function GzFunc(params) {
|
||||
console.log("初始化");
|
||||
}
|
||||
GzFunc.prototype.hdyyds = function (params) {
|
||||
console.log(params + "(厚渡YYDS)");
|
||||
return this; // 链式调用 核心
|
||||
};
|
||||
|
||||
let xxo = new GzFunc();
|
||||
xxo.hdyyds("第一次调用")
|
||||
.hdyyds("第二次调用")
|
||||
.hdyyds("第三次调用")
|
||||
.hdyyds("第四次调用")
|
||||
|
||||
|
||||
|
||||
// 类
|
||||
// class O {
|
||||
// hdyyds = function (params) {
|
||||
// console.log(params + "(厚渡YYDS)");
|
||||
// return this;
|
||||
// }
|
||||
// }
|
||||
// let xxo = new O();
|
||||
|
||||
// xxo.hdyyds("第一次调用").hdyyds("第二次调用").hdyyds("第三次调用")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user