当前位置: 首页 > news >正文

网站文章怎么做内链网页设计作品集模板

网站文章怎么做内链,网页设计作品集模板,信用公示信息系统(全国),吾爱上云小程序制作1.两种面向编程思想 2.构造函数实现封装以及存在的问题 下面就引出了原型对象 3.原型对象prototype 共享原理图&#xff1a; 4.数组扩展案例-求最大值和数组求和 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><…

1.两种面向编程思想

2.构造函数实现封装以及存在的问题

下面就引出了原型对象

3.原型对象prototype

共享原理图:

4.数组扩展案例-求最大值和数组求和

<!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>// 自己定义 数组扩展方法  求和 和 最大值 // 1. 我们定义的这个方法,任何一个数组实例对象都可以使用// 2. 自定义的方法写到  数组.prototype 身上// 1. 最大值const arr = [1, 2, 3]Array.prototype.max = function () {// 展开运算符return Math.max(...this)// 原型函数里面的this 指向谁? 实例对象 arr}// 2. 最小值Array.prototype.min = function () {// 展开运算符return Math.min(...this)// 原型函数里面的this 指向谁? 实例对象 arr}console.log(arr.max())console.log([2, 5, 9].max())console.log(arr.min())// const arr = new Array(1, 2)// console.log(arr)// 3. 求和 方法 Array.prototype.sum = function () {return this.reduce((prev, item) => prev + item, 0)}console.log([1, 2, 3].sum())console.log([11, 21, 31].sum())</script>
</body></html>

5.constructor属性以及应用

6.对象原型__proto__

7.原型继承

8.原型链以及instanceof运算符

9.综合案例-模态框构造函数写法

<!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><style>.modal {width: 300px;min-height: 100px;box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);border-radius: 4px;position: fixed;z-index: 999;left: 50%;top: 50%;transform: translate3d(-50%, -50%, 0);background-color: #fff;}.modal .header {line-height: 40px;padding: 0 10px;position: relative;font-size: 20px;}.modal .header i {font-style: normal;color: #999;position: absolute;right: 15px;top: -2px;cursor: pointer;}.modal .body {text-align: center;padding: 10px;}.modal .footer {display: flex;justify-content: flex-end;padding: 10px;}.modal .footer a {padding: 3px 8px;background: #ccc;text-decoration: none;color: #fff;border-radius: 2px;margin-right: 10px;font-size: 14px;}.modal .footer a.submit {background-color: #369;}</style>
</head><body><button id="delete">删除</button><button id="login">登录</button><!-- <div class="modal"><div class="header">温馨提示 <i>x</i></div><div class="body">您没有删除权限操作</div></div> --><script>// 1.  模态框的构造函数function Modal(title = '', message = '') {// 公共的属性部分this.title = titlethis.message = message// 因为盒子是公共的// 1. 创建 一定不要忘了加 this this.modalBox = document.createElement('div')// 2. 添加类名this.modalBox.className = 'modal'// 3. 填充内容 更换数据this.modalBox.innerHTML = `<div class="header">${this.title} <i>x</i></div><div class="body">${this.message}</div>`// console.log(this.modalBox)}// 2. 打开方法 挂载 到 模态框的构造函数原型身上Modal.prototype.open = function () {if (!document.querySelector('.modal')) {// 把刚才创建的盒子 modalBox  渲染到 页面中  父元素.appendChild(子元素)document.body.appendChild(this.modalBox)// 获取 x  调用关闭方法this.modalBox.querySelector('i').addEventListener('click', () => {// 箭头函数没有this 上一级作用域的this// 这个this 指向 m this.close()})}}// 3. 关闭方法 挂载 到 模态框的构造函数原型身上Modal.prototype.close = function () {document.body.removeChild(this.modalBox)}// 4. 按钮点击document.querySelector('#delete').addEventListener('click', () => {const m = new Modal('温馨提示', '您没有权限删除')// 调用 打开方法m.open()})// 5. 按钮点击document.querySelector('#login').addEventListener('click', () => {const m = new Modal('友情提示', '您还么有注册账号')// 调用 打开方法m.open()})</script>
</body></html>

http://www.dtcms.com/a/586426.html

相关文章:

  • MPU6050驱动配置
  • linux软件安装与管理
  • 7.基础--SQL--DDL-数据类型及案例
  • 网站内部seo优化包括wordpress主题详情更改版权
  • 网站积分系统方案网络服务商网站
  • 浏览器如何做购物网站为什么网站的备案号在备案网站查询不到
  • COT控制架构下ASP3605负载调整特性评估
  • Java118 反射
  • Optuna超参数调优图例解读之Optimization History Plot(优化历史图)
  • 【Python】Tuple (元组)
  • 小吃培训网站源码广电网络公司优秀营销案例
  • 企业电子商务网站建设设计目的暴雪游戏有哪些
  • 仓颉初使用,资料查找及换进安装使用指导
  • 事务的相关介绍
  • 安徽省工程建设信息网站投资公司设立条件
  • Spring 框架核心技术全解析
  • C# OpenCVSharp使用 读光-票证检测矫正模型
  • 更换空间对网站的影响开发app需要什么设备
  • 佛山网站制作公司沈阳网页设计招聘
  • 南宁比优建站wordpress管理工具栏
  • 企业如何建设自己的网站网站主页跳转index
  • 网站利用百度离线地图淘宝电脑版网页
  • 工业控制网关物联网解决方案软硬件定制:我是你的研发部
  • 第2章 传感器技术与数据处理
  • 【开题答辩全过程】以 房地产销售管理系统为例,包含答辩的问题和答案
  • 建设项目环评验收网站建设行业门户网站需要什么条件
  • maven常用的命令
  • 动态商务网站开发与管理合肥网站建设工作室
  • 设计的网站都有哪些内容新榜数据平台
  • 扶绥县住房和城乡建设局网站品牌网站建设精湛磐石网络