日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dojo中的AMD模式开发案例

發布時間:2024/1/23 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dojo中的AMD模式开发案例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
教程里主要定義了兩個方法,setText設置文本內容和restoreText重置文本內容。
這兩個方法通過 dojo.define這個方法來定義。 // In demo/myModule.js (which means this code defines// the "demo/myModule" module):?define([????// The dojo/dom module is required by this module, so it goes????// in this list of dependencies.????"dojo/dom"], function(dom){????// Once all modules in the dependency list have loaded, this????// function is called to define the demo/myModule module.????//????// The dojo/dom module is passed as the first argument to this????// function; additional modules in the dependency list would be????// passed in as subsequent arguments.?????varoldText = {};?????// This returned object becomes the defined value of this module????return{????????setText:function(id, text){????????????varnode = dom.byId(id);????????????oldText[id] = node.innerHTML;????????????node.innerHTML = text;????????},????????restoreText:function(id){????????????varnode = dom.byId(id);????????????node.innerHTML = oldText[id];????????????deleteoldText[id];????????}????};});
define 方法引用了必要的類,就像java 中的 import;并且還包含了對業務邏輯的實現,
并通過return來返回,以上就是myModule.js文件的全部內容。
那么在html頁面里,通過dojo.require來加載上面的js代碼,
// Require the module we just createdrequire(["demo/myModule"],function(myModule){????// Use our module to change the text in the greeting????myModule.setText("greeting","Hello Dojo!");?????// After a few seconds, restore the text to its original state????setTimeout(function(){????????myModule.restoreText("greeting");????}, 3000);});

?

上面的代碼通常放在<body>內執行。
在這里暫且先總結為:dojo.define 方法僅用于定義和聲明dojo.require 方法僅用于異步加載js文件 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的dojo中的AMD模式开发案例的全部內容,希望文章能夠幫你解決所遇到的問題。

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