1

調べてみましたが、残念ながらこの質問の重複は見つかりませんでした。

ファイル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
   })

既存のプロパティを破棄せずに、継承されたプロパティをどのように拡張しますか?

4

1 に答える 1

0

Require.jsを使用しているようです

行う:

グラフモジュール:

define(function() {
  return Backbone.View.extend({
    move: function() {
    //some stuff
  }
});

サブグラフモジュール:

define(['require', './graph'], function(require) {
  var Graph = require('./graph');

  return Graph.extend({
    // this file needs to inherit what....
  }
});

または、多くの依存関係を定義しない場合は、以下を含めないでくださいrequire

define(['./graph'], function(Graph) {
  return Graph.extend({
    // this file needs to inherit what....
  }
});
于 2012-07-20T21:49:27.577 に答える