命名空间:
 Type.registerNamespace("MyNamespance");
  --注册一个命名空间

类:
 定义步骤
  --定义构造函数
  --定义成员(方法,属性,事件)
  --注册类
 
 构造函数
  类的构造函数即为function定义
  通常用于初始化域变量
  私有成员使用下划线开头(无法真正封装)
   --this._name
   --this._age
  MyNamespace.MyClass =functin(name,age)
  {
   this._name = name;
   this._age = age;
  }
    

 定义方法:
  基于prototype定义
   -- MyNamespace.MyClass.prototype=
    {
     myMethod1:function()
     {
     },
     myMethod2:function()
     {
      this.myMethod();//this保留字不可少
     }
    }
 定义属性
  --Microsoft AJAX Libray的面向对象类型系统set_和get_开头的方法认作属性
  --避免定义只写属性,使用某个方法替代
   MyNamespace.MyClass.prototype =
   {
    get_name:function()
    {
     retrun this._name;
    },
    set_name:funciton(value)
    {
     this._name = value;
    }
   }
  
 注册类:
  MyNamespace.MyClass.registerClass("MyNamespace.MyClass");

 

 1



 

相关文章:

  • 2022-01-23
  • 2022-01-10
  • 2022-01-08
  • 2022-01-17
  • 2021-08-18
猜你喜欢
  • 2021-12-23
  • 2021-11-01
  • 2021-07-15
  • 2021-08-29
  • 2021-07-31
  • 2021-05-17
  • 2021-10-10
相关资源
相似解决方案