假设我有这个结构:
文件1.js:
var myObject = {
bindEvents: function() {
console.log('Root events binding');
}
}
键盘对象.js:
myObject.bindEvents: function() {
console.log('Keyboard events binding');
}
鼠标对象.js:
myObject.bindEvents: function() {
// extends original bindEvents and adds more functionality
// right now this behavior overrides the original bindEvents method
console.log('Mouse events binding');
}
如何触发myObject.bindEvents()
并确保在每个文件中触发它?
我的目的是将一个大对象拆分为单独的文件,并创建一种方法来触发每个文件中的所有相应方法,如bindEvents
应该在对象中触发bindEvents
(或keyboardEvents
在我的情况下)