Javascript 敲除JS html绑定返回奇怪的代码而不是html字符串
我不知道这里发生了什么。下面是我应用它的绑定。我尝试了html和文本绑定Javascript 敲除JS html绑定返回奇怪的代码而不是html字符串,javascript,knockout.js,Javascript,Knockout.js,我不知道这里发生了什么。下面是我应用它的绑定。我尝试了html和文本绑定 <h1>function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}</h1>function c(){if(0<arguments.leng
<h1>function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}</h1>function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}
顺便说一句,computed observabletournamentID
非常有效,语法似乎完全相同。我认为当我在计算的可观察对象中使用self.name
时会出现问题。有什么想法吗?试试这个
<span data-bind="text: flyer"></span>
想想看。你得到了什么?您可以得到函数定义。因为您将函数传递给了
计算的。您需要传递值。你应使用:
<span data-bind="text: flyer()"></span>
self.flyer=ko.computed(函数(){
返回“”+self.name()+“”+self.image();
});
因为name
和image
都是可观察的(从JavaScript的角度来看:函数)
我不知道为什么tournamentID
对您有效。不应该
顺便说一句,如果您使用的是var self=this
,那么您可以省略computed
的第二个参数,谢谢您的回答。我总是错过一些愚蠢的事情。也谢谢你解释你的答案,而不是仅仅提供固定的代码。有了理论,就意味着有了代码。
<span data-bind="text: flyer()"></span>
self.flyer = ko.computed(function(){
return '<h1>'+self.name()+'</h1>'+self.image();
});