2
除了使用他们在文档中说的内容外,是否有扩展KnockoutObservableAny
的方法?扩展Knockoutjs对象
ko.extenders.logChange = function(target, option) {
target.subscribe(function(newValue) {
console.log(option + ": " + newValue);
});
return target;
};
通过调用:
this.firstName = ko.observable("Bob").extend({logChange: "first name"});
我宁愿(因为我使用的打字稿与智能感知)来调用它直接关闭对象,但我想不出什么地方进行访问的方式构造我可以为JQuery
。
(function ($) {
$.fn.foo = function() {
};
})(jQuery);
那么我可以称它为$().foo();
。
任何想法?