{"id":945,"date":"2019-06-10T21:55:43","date_gmt":"2019-06-10T12:55:43","guid":{"rendered":"https:\/\/ito-u-oti.com\/?p=945"},"modified":"2019-06-10T21:55:47","modified_gmt":"2019-06-10T12:55:47","slug":"post-945","status":"publish","type":"post","link":"https:\/\/ito-u-oti.com\/?p=945","title":{"rendered":"\u3010RequireJS\u3011config\u306e\u8a2d\u5b9a\u65b9\u6cd5\u306e\u9055\u3044"},"content":{"rendered":"\n<p><a href=\"https:\/\/ito-u-oti.com\/post-928\/\">\u524d\u56de\u8a18\u4e8b<\/a>\u304b\u3089\u306e\u7d9a\u304d\u3067\u3059\u3002<br>RequireJS\u3067\u306f\u5b9a\u7fa9\u3057\u305fjs\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u6642\u306b\u3001\u76f8\u5bfe\u30d1\u30b9\u6307\u5b9a\u3092\u7701\u7565\u3067\u304d\u308b\u3088\u3046\u306bconfig\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>html\u304b\u3089requireJS\u3092\u8aad\u307f\u8fbc\u3093\u3060\u969b\u306b\u3001config\u306e\u8a2d\u5b9a\u65b9\u6cd5\u306b\u3064\u3044\u3066\u9055\u3044\u304c\u4e8c\u3064\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__1\" class=\"wp-block-heading\">\u524d\u63d0<\/h2>\n\n\n\n<p>\u524d\u56de\u3068\u540c\u3058HelloWorld.js\u306e\u30bd\u30fc\u30b9\u3092\u7528\u3044\u307e\u3059\u3002<br>\u4eca\u56de\u306fHelloWorld.js\u3068util.js\u306b\u5dee\u5206\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>HelloWorld.js<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nrequire(&#x5B;'util'], function(util) {\n    var result = util.add(10, 21);\n    console.log('10 + 21 = ' + result);\n});\n<\/pre><\/div>\n\n\n<p>util.js<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\ndefine(function() {\n    return {\n        add: function(a, b) {\n            return a + b;\n        }\n    }\n})\n<\/pre><\/div>\n\n\n<h2 id=\"outline__2\" class=\"wp-block-heading\">requireJS\u3092\u8aad\u307f\u8fbc\u3093\u3060\u5f8c\u306bconfig\u3092\u8a2d\u5b9a\u3059\u308b<\/h2>\n\n\n\n<p>\u591a\u5206\u3053\u3063\u3061\u306e\u307b\u3046\u304c\u738b\u9053\u3002<br>requireJS\u3092\u8aad\u307f\u8fbc\u307f\u3001require.config\u3067\u8a2d\u5b9a\u3059\u308b\u3002<\/p>\n\n\n\n<h3 id=\"outline__2_1\" class=\"wp-block-heading\"> index.html <\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;ja&quot;&gt;\n    &lt;head&gt;\n        &lt;meta charset=&quot;utf-8&quot;&gt;\n        &lt;title&gt;&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;script src=&quot;https:\/\/requirejs.org\/docs\/release\/2.3.6\/minified\/require.js&quot;&gt;&lt;\/script&gt;\n        &lt;script src=&quot;.\/js\/config\/config.js&quot;&gt;&lt;\/script&gt;\n        &lt;script src=&quot;.\/js\/HelloWorld.js&quot;&gt;&lt;\/script&gt;\n        &lt;h1&gt;Hello World!&lt;\/h1&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<h3 id=\"outline__2_2\" class=\"wp-block-heading\">config.js<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nrequire.config({\n    baseUrl: &quot;js&quot;,\n    paths: {\n        &quot;util&quot;: &quot;lib\/util&quot;\n    }\n});\n<\/pre><\/div>\n\n\n<h2 id=\"outline__3\" class=\"wp-block-heading\"> requireJS\u3092\u8aad\u307f\u8fbc\u3080\u3088\u308a\u524d\u306bconfig\u3092\u8a2d\u5b9a\u3059\u308b<\/h2>\n\n\n\n<p>\u305f\u307e\u306b\u898b\u304b\u3051\u308b\u3002<br>\u5148\u306brequire\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3067config\u60c5\u5831\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u3001\u5f8c\u304b\u3089requireJS\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5<\/p>\n\n\n\n<h3 id=\"outline__3_1\" class=\"wp-block-heading\">index.html<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;ja&quot;&gt;\n    &lt;head&gt;\n        &lt;meta charset=&quot;utf-8&quot;&gt;\n        &lt;title&gt;&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;script src=&quot;.\/js\/config\/config.js&quot;&gt;&lt;\/script&gt;\n        &lt;script src=&quot;https:\/\/requirejs.org\/docs\/release\/2.3.6\/minified\/require.js&quot;&gt;&lt;\/script&gt;\n        &lt;script src=&quot;.\/js\/HelloWorld.js&quot;&gt;&lt;\/script&gt;\n        &lt;h1&gt;Hello World!&lt;\/h1&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<h3 id=\"outline__2_2\" class=\"wp-block-heading\">config.js<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nvar require = {\n    baseUrl: &quot;js&quot;,\n    paths: {\n        &quot;util&quot;: &quot;lib\/util&quot;\n    }\n};\n<\/pre><\/div>\n\n\n<h2 id=\"outline__4\" class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3053\u306e\u5834\u5408\u3001index.html\u304b\u3089\u898b\u3066<br>.\/js\/lib\/util\u914d\u4e0b\u306butil.js\u304c\u3042\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br>\u305d\u308c\u3092HelloWorld.js\u3067\u306frequire\u306butil\u3092\u5ba3\u8a00\u3059\u308b\u3060\u3051\u3067util.js\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u8a18\u4e8b\u304b\u3089\u306e\u7d9a\u304d\u3067\u3059\u3002RequireJS\u3067\u306f\u5b9a\u7fa9\u3057\u305fjs\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u6642\u306b\u3001\u76f8\u5bfe\u30d1\u30b9\u6307\u5b9a\u3092\u7701\u7565 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":933,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[211,1],"tags":[219,216,213],"class_list":["post-945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-1","tag-config","tag-require","tag-requirejs"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=945"}],"version-history":[{"count":1,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/945\/revisions"}],"predecessor-version":[{"id":946,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/945\/revisions\/946"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/media\/933"}],"wp:attachment":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}