我周圍搜索,但不幸的是,還沒有找到這個問題的重複。在JavaScript中,如何繼承和擴展正在繼承的方法?
文件1:
var Graph = Backbone.View.extend({
move: function() {
//some stuff
}, //more stuff
})
文件2:
define ([ './graph.js' ]), function(graph) {
var SubGraph = Backbone.View.extend({
// this file needs to inherit what is within the move method but extend it to include other stuff
})
你如何在不破壞現有的延長繼承的屬性?
你能提供更多關於你的期望的細節嗎? – Lucero 2012-07-20 21:43:19
我認爲你可以做'var SubGraph = Graph.extend(...',爲了設置繼承,但我不確定...(我過去只有一次處理骨幹) – 2012-07-20 21:45:24