zoukankan      html  css  js  c++  java
  • 一个面向对象的JS例子,很好的支持了开闭原则(不要重复你昨天的代码)

    <script type="text/javascript">
        //一个面向对象的JS例子,很好的支持了开闭原则
        function HtmlControl(options) {//定义一个方法
            var el = options.element;
            el.style.width = options.width;
            el.style.height = options.height;
            el.style.top = options.top;
            el.style.background = options.background;
        }
     
        var option = { //为方法定义一个参数对象
            element: document.getElementById('test'),
            left: 50,
            top: 0,
             100,
            height: 200,
            background: '#f00'
        }
        option.background = '#ff0'; //对参数对象进行扩展
     
        HtmlControl(option); //调用
    </script>
  • 相关阅读:
    Ubuntu 系统下载
    Shell 变量自增实现方法
    shell 单引号以及双引号
    A look at WeChat security
    利用HTTP Cache来优化网站
    require.js 简洁入门
    Nginx rewrite URL examples with and without redirect address
    页面制作部分之PS切图
    Joda-Time 简介
    [官方摘要]Setup And Configuration memcached with Tomcat
  • 原文地址:https://www.cnblogs.com/lori/p/2178332.html
Copyright © 2011-2022 走看看