从零开始学习前端JAVASCRIPT — 12、JavaScript面向对象编程
2018-02-28 19:43
645 查看
一、构造函数的使用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>面向对象编程</title> </head> <body> <script> /*构造函数(构造函数命名一般此采用大驼峰式命名即驼峰式命名首字母大写)*/ // 构造函数中的this指向的是即将生成的对象 // ES5的语法 function Es5Person(name) { this.name = name; this.sleep = function () { console.log('喜欢睡觉!'); }; } // ES6语法 class Es6Person { constructor(name) { this.name = name; } //定义方法省略关键字,且方法直接绑定到原型对象 sleep() { console.log('喜欢睡觉!'); } } var personOne = new Es5Person('小明'); var personTwo = new Es6Person('小张'); console.log(personOne); console.log(personTwo); </script> </body> </html>
/* contaiter 模态框背景层 */ .contaiter{ width: 100%; height: 100%; overflow: hidden; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10050; background: rgba(0,0,0,.1); } /* modal-dialog 模态框弹出框 */ .modal-dialog{ margin: 40px auto; width: 50%; border-radius: 15px; border: 1px dashed #f4f4f4; background: #ffffff; box-shadow: 0 0 10px #000000; outline: none; } /* modal-close 关闭模态框 */ .modal-close{ position: absolute; font-size: 36px; color: #000000; right: 20px; top: 10px; } /* modal-header 模态框头部 */ .modal-header{ position: relative; padding: 20px; border-bottom: 1px dashed #f4f4f4; } .modal-title{ font-size: 16px; } /* modal-content 模态框内容区 */ .modal-content{ padding: 20px; font-size: 16px; } /* modal-footer 模态框底部 */ .modal-footer{ border-top: 1px solid #f4f4f4; padding: 20px; text-align: right; } .modal-footer input{ margin: 0 10px; display: inline-block; padding: 10px 20px; outline: none; border: 1px solid #555555; background: #ffffff; border-radius: 10px; box-shadow: 0 0 2px #000000; } .modal-footer .commitBtn{ background: #008B00; color: #ffffff; } /* popupBtn */ .popupBtn{ margin: 0 10px; display: inline-block; padding: 10px 20px; outline: none; border: 1px solid #555555; background: #ffffff; border-radius: 10px; box-shadow: 0 0 2px #f4f4f4; background: #ff0000; }
index.css
相关文章推荐
- 从零开始前端学习[12]:css样式中的高级选择器
- 从零开始学习前端JAVASCRIPT — JavaScript中this指向的四种情况
- 【前端学习】javascript面向对象编程(继承和复用)
- 从零开始学习前端JAVASCRIPT — 9、JavaScript基础RegExp(正则表达式)
- WEB前端开发学习----12. JavaScript 选项卡效果
- 从零开始学习前端JAVASCRIPT — 7、JavaScript基础EVENT
- 从零开始前端学习[47]:如何使用javascript来操作行内样式或者属性浅析
- 从零开始前端学习[43]:初识javaScript,前端的行为层
- 韩顺平 javascript教学视频_学习笔记12_js面向对象编程介绍_类(原型对象)和对象
- 从零开始学习前端JAVASCRIPT — 2、JavaScript基础ES5
- 从零开始学习前端JAVASCRIPT — 14、闭包与继承
- 从零开始学习前端JAVASCRIPT — 11、JavaScript运动模型及轮播图效果、放大镜效果、自适应瀑布流
- 从零开始学习前端JAVASCRIPT — 3、JavaScript基础string字符串介绍
- 【前端学习】javascript面向对象编程(继承和复用)
- 从零开始学习前端JAVASCRIPT — 4、JavaScript基础Math和Date对象的介绍
- 从零开始学习前端JAVASCRIPT — 8、JavaScript基础COOKIE
- 从零开始学习前端JAVASCRIPT — 5、JavaScript基础BOM
- 从零开始学习前端开发 — 12、CSS3弹性布局
- 从零开始前端学习[25]:万一你没有UI美工的时候,就要选择阿里矢量图了
- 从零开始学习WEB前端之数据交互(Ajax)