{"id":3543,"date":"2015-02-15T11:42:09","date_gmt":"2015-02-15T03:42:09","guid":{"rendered":"https:\/\/sdeno.com\/?p=3543"},"modified":"2015-02-15T11:42:41","modified_gmt":"2015-02-15T03:42:41","slug":"seajs%e7%ae%80%e5%8d%95%e4%b8%8a%e6%89%8b","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=3543","title":{"rendered":"Seajs\u7b80\u5355\u4e0a\u624b"},"content":{"rendered":"<p style=\"color: #000000;\"><strong>1.\u7b80\u4ecb<\/strong><\/p>\n<p style=\"color: #000000;\">Seajs\uff0c\u4e00\u4e2aWeb\u6a21\u5757\u52a0\u8f7d\u6846\u67b6\uff0c\u8ffd\u6c42\u7b80\u5355\u3001\u81ea\u7136\u7684\u4ee3\u7801\u4e66\u5199\u548c\u7ec4\u7ec7\u65b9\u5f0f\uff0c\uff1aSea.js \u9075\u5faa CMD \u89c4\u8303\uff0c\u6a21\u5757\u5316JS\u4ee3\u7801\u3002\u4f9d\u8d56\u7684\u81ea\u52a8\u52a0\u8f7d\u3001\u914d\u7f6e\u7684\u7b80\u6d01\u6e05\u6670\uff0c\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5458\u66f4\u591a\u5730\u4e13\u6ce8\u7f16\u7801\u3002<\/p>\n<p style=\"color: #000000;\"><strong>2.\u4f18\u7f3a\u70b9<\/strong><\/p>\n<p style=\"color: #000000;\">\u4f18\u70b9\uff1a<br \/>\n1).\u63d0\u9ad8\u53ef\u7ef4\u62a4\u6027\u3002<br \/>\n2).\u6a21\u5757\u5316\u7f16\u7a0b\u3002<br \/>\n3).\u52a8\u6001\u52a0\u8f7d\uff0c\u524d\u7aef\u6027\u80fd\u4f18\u5316<\/p>\n<p style=\"color: #000000;\">\u7f3a\u70b9\uff1a<br \/>\n1).\u5b66\u4e60\u6587\u6863\u504f\u5c11\u4e14\u6df7\u4e71\uff0c\u4f1a\u66f4\u6539\u56e2\u961f\u4f7f\u7528JS\u7684\u7f16\u5199\u4e60\u60ef\uff0c\u5fc5\u987b\u4f7f\u7528\u6a21\u5757\u5316\u7f16\u7a0b\u3002<br \/>\n2).\u4e0d\u592a\u9002\u5408\u56e2\u961f\u76ee\u524d\u7684\u60c5\u51b5\uff0c\u591aJS\u6587\u4ef6\u4f46\u5c11\u6539\u52a8\uff0c\u52a8\u6001\u52a0\u8f7d\u4f18\u52bf\u548c\u6a21\u5757\u5316\u4f18\u52bf\u4e0d\u660e\u663e\u3002<br \/>\n3). \u9700\u8981\u914d\u5957\u4f7f\u7528SPM\u5de5\u5177\uff0cJS\u7684\u6253\u5305\u548c\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<p style=\"color: #000000;\"><strong>2.\u4ec0\u4e48\u662fCMD \u548cAMD \uff1f<\/strong><\/p>\n<p style=\"color: #000000;\">\u5f02\u6b65\u6a21\u5757\u5b9a\u4e49\uff08AMD\uff09\u662fAsynchronous Module Definition\u7684\u7f29\u5199\uff0c\u662f RequireJS \u5728\u63a8\u5e7f\u8fc7\u7a0b\u4e2d\u5bf9\u6a21\u5757\u5b9a\u4e49\u7684\u89c4\u8303\u5316\u4ea7\u51fa\u3002<br \/>\n\u901a\u7528\u6a21\u5757\u5b9a\u4e49\uff08CMD\uff09\u662fCommon Module Definition\u7684\u7f29\u5199\uff0c\u662fSeaJS \u5728\u63a8\u5e7f\u8fc7\u7a0b\u4e2d\u5bf9\u6a21\u5757\u5b9a\u4e49\u7684\u89c4\u8303\u5316\u4ea7\u51fa\u3002<br \/>\nRequireJS \u548c SeaJS \u90fd\u662f\u6a21\u5757\u5316\u6846\u67b6\u7684\u4ee3\u8868\uff0cAMD\u548cCMD\uff0c\u662f\u4ed6\u4eec\u5404\u81ea\u5b9a\u4e49\u6a21\u5757\u5316\u7684\u65b9\u5f0f\uff0c\u5927\u540c\u5c0f\u5f02\uff0c\u4e3b\u8981\u662f\u4ee3\u7801\u98ce\u683c\u548cAPI\u4e0d\u540c\u3002<\/p>\n<p style=\"color: #000000;\"><strong>3.\u5982\u4f55\u4f7f\u7528\uff1f<\/strong><\/p>\n<pre style=\"color: #000000;\">&lt;script src=\"..\/js\/examples-master\/sea-modules\/seajs\/seajs\/2.1.1\/sea.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n \/\/\u914d\u7f6ejs\u8def\u5f84\r\n seajs.config({\r\n   alias:{\r\n    \"jquery\":\"..\/examples-master\/sea-modules\/jquery\/jquery\/1.10.1\/jquery.js\"\r\n   }\r\n });\r\n \/\/\u52a0\u8f7d\u6a21\u5757\r\n seajs.use('..\/js\/seajs\/init',function($){\r\n   $(\"#test_div\").click(function(){alert(1);});\r\n });\r\n&lt;\/script&gt;<\/pre>\n<p>&nbsp;<\/p>\n<pre><span style=\"color: #000000;\">\/\/init.js<\/span><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">define(function(require,exports,module){<\/span><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">\u00a0\u00a0\u00a0 var $ = require('jquery');<\/span><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">\u00a0\u00a0\u00a0 return $;<\/span><br style=\"color: #000000;\" \/><span style=\"color: #000000;\">});<\/span><\/pre>\n<p><a href=\"http:\/\/www.jb51.net\/article\/47616.htm\" target=\"_blank\">http:\/\/www.jb51.net\/article\/47616.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u7b80\u4ecb Seajs\uff0c\u4e00\u4e2aWeb\u6a21\u5757\u52a0\u8f7d\u6846\u67b6\uff0c\u8ffd\u6c42\u7b80\u5355\u3001\u81ea\u7136\u7684\u4ee3\u7801\u4e66\u5199\u548c\u7ec4\u7ec7\u65b9\u5f0f\uff0c\uff1aSea.js \u9075\u5faa CMD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3543","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/3543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3543"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/3543\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}