knockout.js - knockout computed value of type number returning a concatenated string instead of sum -


पूर्व 1:

  यह अंक = ko.computed & lt; संख्या & gt; (() = & Gt; {this.baseSave () * 1 + (this.ability.modifier () * 1) + this.magic () * 1 + this.miscellaneous () * 1 + this.temporary () * 1;} );   

Ex 2:

  यह अंक = ko.computed & lt; संख्या & gt; (() = & gt; {return.baseSave () + यह Ability.modifier () + this.magic () + this.miscellaneous () + this.temporary ();});   

मैं टाइपोग्राफी के साथ नॉकआउट का उपयोग कर रहा हूं

दिया गया (0, 10, 0, 0, 10)

पूर्व 1 कार्य करता है 20, पूर्व

  निर्यात वर्ग someClass {baseSave: KnockoutObservable & lt; number & gt ;; जैसे स्ट्रिंग के रूप में 0100010 विफल रहता है  

निर्माता () {baseSave = ko.observable & lt; संख्या & gt; (0); }}

क्षमता के अपवाद के साथ जो एक वर्ग है जिसे कंप्यूट किए गए मान वाले वर्ग के निर्माता में दिया जाता है।

जब आप UI से बाइंड करते हैं तो आपको वापस आधारित स्ट्रिंग्स मिलती हैं उपयोगकर्ता के प्रकारों पर 1 के साथ गुणा करना यह एक संख्या बनाता है (जो कि आपको लगता है कि ऐसा होना चाहिए)।

दर्ज करें छवि विवरण यहाँ

Comments

Popular posts from this blog

php - how to change mysql_result($res, 0, "url"); to mysqli -

Delphi: missing interface declarations for UI Automation methods -

android - How to attach an image from an app to gmail -