95 lines
2.3 KiB
HTML
95 lines
2.3 KiB
HTML
<!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>弹出层</title>
|
||
<link rel="stylesheet" href="./css/clear.css">
|
||
<link rel="stylesheet" href="./css/dialog.css">
|
||
</head>
|
||
<body>
|
||
|
||
|
||
<button>登录</button>
|
||
|
||
</body>
|
||
<script src="./js/dialog.js"></script>
|
||
<script>
|
||
// 初始化插件,并传入配置参数
|
||
// 配置参数
|
||
// 插件内部默认的参数
|
||
// 使用者自定义传入的参数
|
||
// 可选参数 必填参数
|
||
|
||
var dia = new Dialog({
|
||
title: '标题222',
|
||
message: '哈哈哈哈',
|
||
confirmButtonText: 'OK',
|
||
showConfirmButton: true,
|
||
|
||
|
||
cancelButtonText: '取消2',
|
||
cancelButtonColor: '',
|
||
|
||
});
|
||
|
||
|
||
|
||
|
||
document.querySelector("button").onclick = () => {
|
||
dia.open();
|
||
// dia.oncancel( function () {
|
||
// console.log("你点击取消2");
|
||
// } );
|
||
dia.onconfirm( function () {
|
||
console.log("你点击确定按钮2");
|
||
} );
|
||
}
|
||
|
||
// var name = "里斯"
|
||
// var test = {
|
||
// name: '张三',
|
||
// getName: () => {
|
||
// console.log("1: ",this);
|
||
// var a = {
|
||
// id: 1,
|
||
// name: '哈哈哈哈',
|
||
// getId: () => {
|
||
// console.log("2: ",this);
|
||
// console.log(this.name); //
|
||
// }
|
||
// }
|
||
|
||
// a.getId()
|
||
|
||
// console.log(this.name);
|
||
// }
|
||
// }
|
||
|
||
// test.getName()
|
||
|
||
// this 墙头草
|
||
// this 在定义的时候无法确定指向谁,this会在被调用的时候确定执行
|
||
// 箭头函数 解绑this作用域
|
||
// 定义一个变量,保存this指向
|
||
|
||
// function demo() {
|
||
// var c = 1;
|
||
// var test = function () {
|
||
// c += 1;
|
||
// return c
|
||
// }
|
||
// return test;
|
||
// }
|
||
|
||
// var a = demo()
|
||
// console.log( a() ); // 2
|
||
// console.log( a() ); // 2
|
||
|
||
// // 闭包 方法内部的方法,内部方法访问外部变量,外部变量会被缓存的过程
|
||
// // 场景:为了避免重复计算,缓存常用的数据
|
||
// // 缺点:导致内存泄漏
|
||
|
||
</script>
|
||
</html> |