JavaScript
Pull request Compare This branch is 1 commit ahead, 20 commits behind aralejs:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
docs
src
tests
.gitignore
.spmignore
.travis.yml
HISTORY.md
Makefile
README.md
package.json

README.md

Base


Build Status Coverage Status

Base 是一个基础类,提供 Class、Events、Attribute 和 Aspect 支持。


使用说明

extend Base.extend(properties)

基于 Base 创建子类。例子:

/* pig.js */
define(function(require, exports, module) {
   var Base = require('base');

   var Pig = Base.extend({
       initialize: function(name) {
           this.name = name;
       },
       talk: function() {
           alert('我是' + this.name);
       }
   });

   module.exports = Pig;
});

具体用法请参考:Class 使用文档

Base 与 Class 的关系

Base 是使用 Class 创建的一个基础类,默认混入了 EventsAttribute 等模块:

/* base.js */
define(function(require) {

    var Class = require('class');
    var Events = require('events');
    var Aspect = require('./aspect');
    var Attribute = require('./attribute');

    var Base = Class.create({
        Implements: [Events, Aspect, Attribute],

        initialize: function(config) {
            ...
        },

        ...
    });

    ...
});

具体用法请参考: