语法 @mixin [<MixinName>] 概述 混合提供旨在添加到其他对象的功能。如果需要,可以使用 @mixin 标记来表明一个对象是一个混合。然后可以将 @mixes 标记添加到使用该混合的对象。 示例 使用 @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... } }; 相关链接 @borrows@class@mixes