Knockout JS Model Inheritance

前端 未结 5 656
一生所求
一生所求 2020-12-23 17:14

I have three relatively similar knockout models in my application and I would like to extend a base model to combine common properties rather than repeat myself three times.

5条回答
  •  青春惊慌失措
    2020-12-23 18:14

    I think you can use ko.utils.extend like this

    ko.utils.extend(self, new ItemModel(item));
    

    inside the StandardItemModel

    like this: http://jsfiddle.net/marceloandrader/bhEQ6/

提交回复
热议问题