Home > Web Front-end > JS Tutorial > Knockoutjs environment setting tutorial_javascript skills

Knockoutjs environment setting tutorial_javascript skills

WBOY
Release: 2016-05-16 17:47:45
Original
1065 people have browsed it

I will be using Knockoutjs in the project recently, so today I first studied the environment setup of Knockoutjs and conducted a simple test.
First go to http://knockoutjs.com/index.html to download the latest version of Knockoutjs. The author downloaded knockout-2.2.0.js here. Then create a new .html file and add the following statement to the html document to import this js:

At this point we can already write Knockoutjs code. Let's take printing "Hello World!!" as an example and write the following code:

Copy code The code is as follows:





Then use the browser to open this html file, you can see "Hello World!!" words.
In the above code:

A span is defined and data-bind is used to bind helloWorld to the span , so that the content in span is the content in the helloWorld variable.
Copy code The code is as follows:



An AppViewModel is defined in the script, and then a variable is defined for it: helloWorld, whose value is: Hello World!!, and then the ko.applyBindings() method is used to activate the AppViewModel so that this content can be seen on the web page.
The above is just a very simple example using Knockoutjs. During the process of running this example, a small problem occurred, and I am not sure why. The code written before is:
Copy the code The code is as follows:





I put
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template