@mixin
描述:记录一个mixin(混入)对象。
语法
@mixin [<MixinName>]
概述
您可以使用@mixin标签标识该对象是一个mixin(混入),旨在表明该对象的属性和方法混入到其他对象。然后,可以将@mixes标签 添加到使用了该 mixin(混入)的对象上。
例子
例如,使用 @mixin :
/**
* This provides methods used for event handling. It's not meant to
* be used directly.
*
* @mixin
*/
var Eventful = {
/**
* Register a handler function to be called whenever this event is fired.
* @param {string} eventName - Name of the event.
* @param {function(Object)} handler - The handler to call.
*/
on: function(eventName, handler) {
// code...
},
/**
* Fire an event, causing all handlers for that event name to run.
* @param {string} eventName - Name of the event.
* @param {Object} eventData - The data provided to each handler.
*/
fire: function(eventName, eventData) {
// code...
}
};