• 基于MVC的JagaScript Web 富应用开发


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>基于MVC的JagaScript Web 富应用开发</title>
    <script>
    var Class = function () {
        var klass = function () {
            this.init.apply(this, arguments);
        };
        
        klass.prototype.init = function () {};
        
        // 定义 prototype 的别名
        klass.fn = klass.prototype;
        
        // 定义类的别名
        klass.fn.parent = klass;
        
        // 给类添加属性
        klass.extend = function (obj) {
          var extended = obj.extended;
            for (var i in obj) {
                klass[i] = obj[i];
            }
            if (extended) extended(klass);
        };
        
        // 给实例添加属性
        klass.include = function (obj) {
            var included = obj.included;
            for (var i in obj) {
                klass.fn[i] = obj[i];
            }
            if (included) included(klass);
        };
        
        return klass;
    };
    
    /*
    // 添加静态属性,将属性复制到类中
    var Person = new Class;
    Person.extend({
      find: function (id) { alert(id); },
        exists: function (id) {}    
    });
    
    var person = Person.find(1);
    */
    
    // 添加实例属性,降属性复制到类的原型中(prototype)
    var Person = new Class;
    Person.include({
        save: function () {},
        destroy: function () {}
    });
    
    var person = new Person;
    person.save();
    
    
    // 支持 extended 和 included 回调。降属性传入对象后就会触发这两个回调
    Person.extend({
      extended: function (klass) {
            console.log(klass, ' was extended!');
        }
    });
    </script>
    </head>
    
    <body>
    </body>
    </html>
  • 相关阅读:
    hive sql常用整理-hive引擎设置
    hdfs数据到hbase过程
    phoenix表操作
    HBase describe table 参数说明
    HBase 常用Shell命令
    sqoop的基本语法详解及可能遇到的错误
    Linux maven 下 jar包下载不下来的解决方法
    Linu 修改maven的setting保护文件
    Mybatis generator 自动生成代码
    Springmvc mvc:exclude-mapping不拦截 无效
  • 原文地址:https://www.cnblogs.com/baie/p/2961611.html
Copyright © 2020-2023  润新知