从 Google Maps Utility Library 查看InfoBubble 的来源,我发现作者使用点符号创建原型方法,但是在方法定义的末尾,他用括号符号重新分配了相同的 proto 属性。
这应该澄清:
/**
* Set the style of the shadow
*
* @param {number} shadowStyle The style of the shadow.
*/
InfoBubble.prototype.setShadowStyle = function(shadowStyle) {
this.set('shadowStyle', shadowStyle);
};
InfoBubble.prototype['setShadowStyle'] = InfoBubble.prototype.setShadowStyle;
任何想法?