विफल रहता है मैं नॉकआउट जेएस (http://goo.gl/lddLl से) के लिए एक बहुत ही सरल हैलो दुनिया कर रहा हूं: लेकिन मेरा कोड एक त्रुटि उत्पन्न कर रहा है जिसे मैं समझ नहीं पा रहा हूं। knockout- से 2439Knockout.js - सरल "हैलो वर्ल्ड"
:
Uncaught TypeError: संपत्ति पढ़ा नहीं जा सकता अशक्त नॉकआउट-3.0.0.debug.js की 'nodeType'
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AJAX Example</title>
<script src="../Scripts/jquery-2.0.3.js"></script>
<script src="../Scripts/knockout-3.0.0.debug.js"></script>
<script>
// Here's my data model
var ViewModel = function (first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
this.fullName = ko.computed(function() {
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
return this.firstName() + " " + this.lastName();
}, this);
};
ko.applyBindings(new ViewModel("Planet", "Earth")); // This makes Knockout get to work
</script>
</head>
<body>
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
</body>
</html>
ko.applyBindings कॉल त्रुटि को जन्म देती है 3.0.0.debug.js कोड:
// Perf optimisation: Apply bindings only if...
// (1) We need to store the binding context on this node (because it may differ from the DOM parent node's binding context)
// Note that we can't store binding contexts on non-elements (e.g., text nodes), as IE doesn't allow expando properties for those
// (2) It might have bindings (e.g., it has a data-bind attribute, or it's a marker for a containerless template)
var isElement = (nodeVerified.nodeType === 1);
मैं भी पता करने के लिए मैं गलत तरीके से क्या कर रहा हूँ ... अज्ञानी
/शर्मिंदा। आपके शिक्षण के लिए धन्यवाद! – TheFastCat
कोई चिंता नहीं। खुश है कि मदद करता है! –