Original address: http://6yang.net/articles_view.php?id=1103
2011-10-18 13:12:01 by "6yang", 1029 visits, Favorites | back
Example Description:
Demo[require]: http://6yang.net/myjavascriptlib/requirejs/demo/d1.html
Demo[require-define]: http://6yang.net/myjavascriptlib/requirejs/demo/d2.html
Demo[require-config]: http://6yang.net/myjavascriptlib/requirejs/demo/d3.html
Description under Require,require-define,require-config,app-bulid.js (introduction)
Require: The main tasks include asynchronous loading events and JS libraries.
Define: The primary task defines the event for easy invocation.
Require.config (): main task configuration related parameters.
App-bulid.js: The app-build.js is created for the Nodejs creation of the project used, the allocation directory.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>requirejs Applications </title>
<style>
</style>
<body>
<!--<script src= "Js/jquery-1.6.2.min.js" ></script>-->
<script src= "Js/require.js" ></script>
<script>
Define ("Employee", function () {
You can name the This function here,
which can help in debuggers but
Have no impact on the module name.
return function Employee (first, last) {
This.first = First;
This.last = Last;
};
});
/*
Define ("main", ["employee"], function (employee) {
var john = new Employee ("John", "Smith");
alert (John.first);
});*/
/*
@ At this time the require includes the object variables defined in the Define and the loading JS file object.
The employee in the @ function (employee) is required to pass the parameter through the variables in the define;
*/
require (["Employee", "Js/test", "http://code.jquery.com/jquery-1.6.4.min.js"], function (employee) {
var john = new Employee ("John", "Smith");
Alert (John.first)
alert (objstu.country);
var inputval = $ ("Input:checkbox"). Prop ("name");
alert (inputval);
});
</script>
<div id= "dic" >sssssssssssss</div>
User name: <input type= "text" name= "username" value= "1244555"/><br/>
Gender: <input type= "checkbox" name= "Sex" value= "0"/>
</body>
share to:0 I want to comment this article from: http://www.6yang.net/articles_view.php?id=1103
Requirejs-define jquery Quick Beginner Example (i)