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

网站设计分辨率站长素材音效网

网站设计分辨率,站长素材音效网,企业做网站的多吗,微信小程序制作软件下载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/wzjs/137205.html

相关文章:

  • 珠海在线网站建设公司企业员工培训
  • Linux备份wordpress北京seo相关
  • 新郑做网站优化南宁百度seo价格
  • 绵阳网站开发公司国际新闻最新消息今天 新闻
  • 郑州专业网站建设兰州网络推广的平台
  • 网站制作工资网络优化器免费
  • 网页做网站的尺寸电子报刊的传播媒体是什么
  • 网络设计的步骤肇庆seo按天收费
  • wordpress文章名seo交流群
  • 石家庄网站制作仓谷长春seo排名公司
  • 怎么找网红合作卖东西网站做优化一开始怎么做
  • 怎样做淘宝的导购网站推广网络营销方案策划案例
  • php政府网站怎么去做网络推广
  • 公司请人做公司网站会计分录百度经验
  • 自助建网站系统成都纯手工seo
  • 如何建网站教程怎么在百度上做推广
  • 昆明做网站哪家便宜百度资源站长平台
  • 广州做网站一般要多少钱?郑州网络优化实力乐云seo
  • 网站一般用什么软件做搜索seo引擎
  • 效果型网站建设b站是哪个网站
  • 公司做网站建设seo做关键词怎么收费的
  • 宁波公司网站建设长春网站建设方案优化
  • 邢台网红排行榜seo百度seo排名优化软件
  • 中国人做网站卖美国人百度指数怎样使用
  • 外贸网站建设注意事项和建议仁茂网络seo
  • 太原做手机网站最新疫情最新情况
  • 无锡网站建设 首选无锡立威云商山东seo优化
  • 网站平台建设规划中企动力做网站推广靠谱吗
  • ui设计哪里培训机构seo案例分析及解析
  • 深圳龙华做网站的朋友圈推广