zoukankan      html  css  js  c++  java
  • ExtJS类的继承

    ExtJS类的继承主要是在定义类的时候指定其extend属性指向其需要继承的类

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>05_inherit.html</title>
       
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">商账追收
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
       
        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
        <script type="text/javascript" src="../ext4/ext-all-debug.js"></script>
        <script type="text/javascript">
            Ext.onReady(function() {
                Ext.namespace("com.tiantian.test");
                com.tiantian.test.Person = function() {//定义一个对象
                    this.name = "默认名称";
                    this.age = 0;
                    this.country = "中国";
                }
                //也可以这样定义一个对象
                Ext.define("com.tiantian.test.Person1",{
                    name: "person1",
                    age: 30
                });
                Ext.define("com.tiantian.test.Student",{
                    extend: "com.tiantian.test.Person",//表示继承自哪个类
                    constructor: function(name, age) {//构造方法
                        this.name = name;
                        this.age = age;
                    },
                    role: "学生",
                    country: "新加坡",
                    getRole: function() {
                        return this.role;
                    }
                });
                Ext.define("com.tiantian.test.Teacher",{
                    extend: "com.tiantian.test.Person",
                    country: "马来西亚",
                    role: "老师"
                });
                var student = new com.tiantian.test.Student("张三",3);
                alert("name:"+student.name+" age:"+student.age+" role:"+student.role+student.getRole()+" country:"+student.country);
                var person1 = new com.tiantian.test.Person1();
                alert(person1.name);女装品牌排行榜
                var teacher = new com.tiantian.test.Teacher();
                teacher.name = "李四";
                teacher.age = 30;
                alert("name:"+teacher.name+" age:"+teacher.age+" role:"+teacher.role+" country:"+teacher.country);
            });
        </script>

      </head>
     
      <body>
        This is my HTML page. <br>
      </body>
    </html>

  • 相关阅读:
    到底如何设置 Java 线程池的大小?
    面试一个 3 年 Java 程序员,一个问题都不会!
    Spring Boot 集成 Ehcache 缓存,三步搞定!
    牛逼哄哄的 "零拷贝" 是什么?
    一个 Java 字符串到底有多少个字符?
    不用找了,300 分钟帮你搞定 Spring Cloud!
    五分钟搞懂 Linux 重点知识,傻瓜都能学会!
    如何设计一个完美的权限管理模块?
    Redis基础都不会,好意思出去面试?
    .net c# MVC提交表单的4种方法
  • 原文地址:https://www.cnblogs.com/sky7034/p/2077277.html
Copyright © 2011-2022 走看看