requirejs-define jquery 快速初學執行個體(一)

來源:互聯網
上載者:User

標籤:

原文地址:http://6yang.net/articles_view.php?id=1103

2011-10-18 13:12:01 by 【6yang】, 1029 visits, 收藏 | 返回

執行個體說明:

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

 

說明下require,require-define,require-config,app-bulid.js(介紹)

require: 主要任務包括非同步載入事件及js庫。

define: 主要任務定義事件方便調用。

require.config(): 主要任務配置相關參數。

app-bulid.js: 建立app-build.js為是了nodejs建立項目使用的,分配目錄。

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>requirejs 應用</title>
</head>
<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 this function here,
    //which can help in debuggers but
    //has 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);
});*/

/*  
 @ 這時的require包括了define裡定義的物件變數及載入js檔案對象.
 @ function(Employee)裡的Employee,是需要通過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>
使用者名稱:<input type="text" name="username" value="1244555" /><br/>
性別: <input type="checkbox" name="sex" value="0" /> 
</body>
</html>

 

分享到:0我要評論本文來自:http://www.6yang.net/articles_view.php?id=1103

requirejs-define jquery 快速初學執行個體(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.