{"id":5373,"date":"2023-11-08T18:10:04","date_gmt":"2023-11-08T09:10:04","guid":{"rendered":"https:\/\/www.lining-moon.casa\/andplus.co.jp\/?p=5373"},"modified":"2023-11-08T18:10:04","modified_gmt":"2023-11-08T09:10:04","slug":"post-5373","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/post-5373\/","title":{"rendered":"\u30da\u30fc\u30b8\u306e\u7279\u5b9a\u306e\u90e8\u5206\u3092\u3001template\u306b\u7f6e\u304d\u63db\u3048\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u30a6\u30a7\u30d6\u958b\u767a\u306b\u304a\u3044\u3066\u3001\u30da\u30fc\u30b8\u306e\u7279\u5b9a\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u52d5\u7684\u306b\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3057\u3070\u3057\u3070\u3042\u308a\u307e\u3059\u3002JavaScript\u3092\u4f7f\u7528\u3057\u3066\u3053\u306e\u3088\u3046\u306a\u52d5\u7684\u306a\u7f6e\u304d\u63db\u3048\u3092\u884c\u3046\u65b9\u6cd5\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b\u5229\u70b9<\/h2>\n<p>HTML5\u306e<code>&lt;template&gt;<\/code>\u30bf\u30b0\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u3067\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3092\u5f85\u6a5f\u3055\u305b\u308b\u3053\u3068\u306a\u304f\u3001\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u6e96\u5099\u3067\u304d\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u3053\u306e\u30bf\u30b0\u5185\u306b\u914d\u7f6e\u3055\u308c\u305f\u5185\u5bb9\u306f\u3001\u30da\u30fc\u30b8\u306e\u8aad\u307f\u8fbc\u307f\u6642\u306b\u306f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u307e\u305b\u3093\u304c\u3001JavaScript\u3092\u4f7f\u7528\u3057\u3066\u5fc5\u8981\u306a\u6642\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3057\u3001\u30da\u30fc\u30b8\u306b\u633f\u5165\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>JavaScript\u306b\u3088\u308b\u52d5\u7684\u7f6e\u304d\u63db\u3048<\/h2>\n<p>&nbsp;<\/p>\n<h3>\u30b9\u30c6\u30c3\u30d7 1: \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u6e96\u5099<\/h3>\n<p>\u307e\u305a\u3001\u7f6e\u304d\u63db\u3048\u305f\u3044\u5185\u5bb9\u3092<code>&lt;template&gt;<\/code>\u30bf\u30b0\u5185\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u5404\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u306f\u4e00\u610f\u306e<code>data-id<\/code>\u5c5e\u6027\u3092\u4ed8\u4e0e\u3057\u3066\u8b58\u5225\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"language-html\"><code>\n  &lt;template class=\"goreinu-template\" data-id=\"uniqueId\"&gt;\n  &lt;!-- \u3053\u3053\u306b\u7f6e\u304d\u63db\u3048\u305f\u3044\u5185\u5bb9\u3092\u5165\u308c\u307e\u3059 --&gt;\n&lt;\/template&gt;\n<\/code><\/pre>\n<h3><\/h3>\n<h3>\u30b9\u30c6\u30c3\u30d7 2: \u7f6e\u304d\u63db\u3048\u5bfe\u8c61\u306e\u8981\u7d20\u3092\u30de\u30fc\u30af<\/h3>\n<p>\u6b21\u306b\u3001\u7f6e\u304d\u63db\u3048\u305f\u3044\u8981\u7d20\u306b<code>class=\"goreinu-inplace\"<\/code>\u3068\u7279\u5b9a\u306e<code>data-id<\/code>\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"language-html\"><code>\n&lt;div class=\"goreinu-inplace\" data-id=\"uniqueId\"&gt;&lt;\/div&gt;\n<\/code><\/pre>\n<h3><\/h3>\n<h3>\u30b9\u30c6\u30c3\u30d7 3: JavaScript\u3067\u306e\u7f6e\u304d\u63db\u3048\u51e6\u7406<\/h3>\n<p>\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u30ed\u30fc\u30c9\u3055\u308c\u305f\u308a\u3001\u30ea\u30b5\u30a4\u30ba\u3055\u308c\u305f\u308a\u3057\u305f\u3068\u304d\u306b\u7f6e\u304d\u63db\u3048\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u306e\u95a2\u6570\u306f\u3001<code>data-id<\/code>\u5c5e\u6027\u3092\u4f7f\u3063\u3066\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u7f6e\u304d\u63db\u3048\u5bfe\u8c61\u306e\u8981\u7d20\u3092\u95a2\u9023\u4ed8\u3051\u3001\u5185\u5bb9\u3092\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"language-javascript\"><code>\n(function () {\n  let templates = {}; \/\/ \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\n  \n  let replaceContent = function () {\n    document.querySelectorAll(\".goreinu-inplace\").forEach((inplace) =&gt; {\n      let dataId = inplace.getAttribute('data-id');\n      if (!templates[dataId]) {\n        let tmpl = document.querySelector('.goreinu-template[data-id=\"' + dataId + '\"]');\n        templates[dataId] = document.importNode(tmpl.content, true);\n      }\n      inplace.replaceWith(templates[dataId].cloneNode(true));\n    });\n  };\n  window.addEventListener('load', replaceContent);\n  window.addEventListener('resize', replaceContent);\n  })();\n<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u30da\u30fc\u30b8\u306e\u30ed\u30fc\u30c9\u6642\u3068\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30ea\u30b5\u30a4\u30ba\u6642\u306b\u3001\u6307\u5b9a\u3055\u308c\u305f<code>data-id<\/code>\u3092\u6301\u3064\u8981\u7d20\u3092\u5bfe\u5fdc\u3059\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u5185\u5bb9\u3067\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<h2><\/h2>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3048\u3070\u3001\u30da\u30fc\u30b8\u306e\u7279\u5b9a\u306e\u90e8\u5206\u3092\u52b9\u7387\u7684\u306b\u52d5\u7684\u306b\u66f4\u65b0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u3088\u308a\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306b\u3001\u305d\u3057\u3066\u53cd\u5fdc\u7684\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u3053\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u305c\u3072\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>","protected":false},"excerpt":{"rendered":"\u30a6\u30a7\u30d6\u958b\u767a\u306b\u304a\u3044\u3066\u3001\u30da\u30fc\u30b8\u306e\u7279\u5b9a\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u52d5\u7684\u306b\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3057\u3070\u3057\u3070\u3042\u308a\u307e\u3059\u3002JavaScript\u3092\u4f7f\u7528\u3057\u3066\u3053\u306e\u3088\u3046\u306a\u52d5\u7684\u306a\u7f6e\u304d\u63db\u3048\u3092\u884c\u3046\u65b9\u6cd5\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002 &nbsp; \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b\u5229\u70b9 HTML[...]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"group":[],"pg":[],"class_list":["post-5373","post","type-post","status-publish","format-standard","category-javascript"],"acf":[],"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/5373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=5373"}],"version-history":[{"count":0,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/5373\/revisions"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=5373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=5373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=5373"},{"taxonomy":"group","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/group?post=5373"},{"taxonomy":"pg","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/pg?post=5373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}