日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Dojo-API介绍

發布時間:2024/9/20 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Dojo-API介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

網上的關于Dojo的文章很多,我從項目經歷上闡述自己的一些用法、示例,僅供參考。Dojo是一個強大的面向對象JavaScript框架。主要由三大模塊組成:Core、Dijit、DojoX。Core提供Ajax,events,packaging,CSS-based querying,animations,JSON等相關操作API。Dijit是一個可更換皮膚,基于模板的WEB UI控件庫。DojoX包括一些創新/新穎的代碼和控件:DateGrid,charts,離線應用,跨瀏覽器矢量繪圖等。

?? ? ??-------獲取dojo相關對象-----------

?? ? ? 1.dojo.byId() :等同于?document.getElementById(),根據DOM節點的ID獲取該節點DOM對象。

?? ? ? 2.dijit.byId()?:?是獲取由dojo widget 系統創建的對象,然后你可以調用這個這個對象的方法或改變這個對象的屬性。

?? ? ? -------dojo監聽事件-----------

?? ? ? 3.dojo.connect() :為前端操作創建事件監聽器.

/* Set up a connection */dojo.connect(/*Object|null*/ obj,/*String*/ event,/*Object|null*/ context,/*String|Function*/ method) // Returns a Handle

?? ? ??4. dojo.disconnect(/*Handle*/handle);?? 解除注冊監聽器?/* Tear down a connection */

?? ? ? --------dojo的json處理----------

?? ? ? 5.dojo.fromJson(/*String*/ json) //把json string轉化為json object

?? ? ? 6.dojo.toJson(/*Object*/ json, /*Boolean?*/ prettyPrint) //把json?object轉化為json?string.

var o = {a:1, b:2, c:3, d:4};dojo.toJson(o, true); //pretty print/* produces ...'{"a": 1,"b": 2,"c":3,"d":4}'

?? ?-------dojo的ajax操作-----------

?? ? ? ?7.dojo.xhrGet(/*Object*/args) ?:ajax的GET提交

dojo.addOnLoad(function( ) {dojo.xhrGet({url : "someText.html", //the relative URL// Run this function if the request is successfulload : function(response, ioArgs) {console.log("successful xhrGet", response, ioArgs);dojo.byId("foo").innerHTML= response; //always return the response back},// Run this function if the request is not successfulerror :function(response, ioArgs) {console.log("failed xhrGet", response, ioArgs);}});});

?? ? ? ?8.dojo.xhrPost(/*Object*/args)?:ajax的POSt提交,支持text、json、xml等提交形式。

dojo.xhrPost({url : "/place/to/post/some/raw/data",postData : "{foo : 'bar'}", //a JSON literalhandleAs : "json",load : function(response, ioArgs) {/* Something interesting happens here */return response;},error : function(response, ioArgs) {/* Better handle that error */return response;}});

總結

以上是生活随笔為你收集整理的Dojo-API介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。