"Import Html"Àº ´Ù¸¥ HTML ÆÄÀÏÀ» Æ÷ÇÔÇÏ´Â °ÍÀ» ¸»ÇÑ´Ù. Web Component ±â¼úÁß¿¡ Á¤½ÄÀ¸·Î Áö¿øµÇÁö ¾Ê´Â ±â¼úÁßÀÇ ÇϳªÀÌ´Ù. "Import Html"Àº Á¤½ÄÀ¸·Î Áö¿ø ÇÏÁö ¾Ê±â ¶§¹®¿¡ webcomponents.js ÆÄÀÏÀ» ÀÌ¿ëÇØ¾ß ±â¼úÀ» ÀÌ¿ë ÇÒ¼ö ÀÖ´Ù. Å©·ÒÀº "Import Html"À» Áö¿øÇϱ⠶§¹®¿¡ º°µµ·Î webcomponents.js ÆÄÀÏÀÌ ÇÊ¿ä ¾ø´Ù. Å©·ÒÀº Ç÷¡±×¸¦ ¼³Á¤ ÇÒ ÇÊ¿äµµ ¾ø°í, À¥¼¹ö¸¸ ±¸Ãà µÇ¾î ÀÖÀ¸¸é µÈ´Ù. ÁÖÀÇ) webcomponents.js¸¦ Á¤½ÄÀ¸·Î Å×½ºÆ® Çغ¸Áø ¾Ê¾Ò´Ù. Å©·Ò À¥ºê¶ó¿ìÁî°¡ Import HtmlÀ» Á¤½ÄÀ¸·Î Áö¿øÇÏ´ÂÁÙ ¸ô¶ú´Ù. ´ÙÀ½ ¶óÀÎÀ» »èÁ¦ ÈÄ¿¡¾ß Å©·Ò À¥ºê¶ó¿ìÁî°¡ Import HtmlÀ» Áö¿øÇÏ´ÂÁö ¾Ë°Ô µÇ¾ú´Ù. <script src="webcomponentsjs-0.7.12/webcomponents.js"></script> Import Html ȯ°æ ±¸Ãà1. webcomponents.js ´Ù¿î·Îµå : http://webcomponents.github.io/webcomponentsjs-0.7.12.zip ÆÄÀÏÀ» ´Ù¿î·Îµå ¹Þ¾Æ¼ À¥¼¹ö home Æú´õ¿¡ ¾ÐÃàÀ» Ǭ´Ù. 2. ¶ÇÇÑ webcomponents.jsÀÇ import htmlÀ» ÀÌ¿ë ÇÒ·Á¸é À¥¼¹ö°¡ ±¸ÃàÀÌ µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. import htmlÀ» Å×½ºÆ® ÇÒ·Á¸é À¥¼¹ö home Æú´õ ¾Æ·¡¿¡¼ ½ÇÇà µÇ¾î¾ß ÇÑ´Ù. Import Html ÀÌ¿ë1. webcomponents.js¸¦ ¸ÞÀÎ HTML¿¡ Æ÷ÇÔ ½ÃŲ´Ù.¿©±â¼´Â HTML head¿¡ ´ÙÀ½ ¶óÀÎÀ» Ãß°¡ ÇÏ¿´´Ù. Å©·Ò¿¡¼´Â ´ÙÀ½ ¶óÀÎÀ» Ãß°¡ÇÒ ÇÊ¿ä°¡ ¾ø´Ù. <script src="webcomponentsjs-0.7.12/webcomponents.js"></script>
2. ÇÊ¿äÇÑ ÀÚ½Ä HTML ÆÄÀÏÀ» Æ÷ÇÔ ½ÃŲ´Ù. "HTML ÆÄÀÏ À̸§"¿¡ °¡Á®¿Ã html ÆÄÀÏ À̸§À» Á¤ÀÇ ÇÏ¸é µÈ´Ù. <link rel="import" href="HTML ÆÄÀÏ À̸§"> <link rel="import" href="box.html">
3. ÀÚ½Ä HTML ÆÄÀÏ ºÒ·¯¿Ã HTML ÆÄÀÏÀº body¸¸ Æ÷ÇÔ ½ÃÄѵµ ½ÇÇàÀÌ µÈ´Ù. <div class="list-item">Include Html Å×½ºÆ®</div>
¹°·Ð ´ÙÀ½°ú °°ÀÌ HTML ±¸¹®ÀÌ ¸ðµÎ Æ÷ÇÔµÈ °æ¿ìµµ »ó°ü ¾ø´Ù. <!DOCTYPE HTML>
<html> <head></head> <body> <div class="list-item">Include Html Å×½ºÆ®</div> </body> </html> 4. ¸ÞÀÎ HTML ÆÄÀÏ ½ºÅ©¸³Æ® ¼³¸í function showTemplate() {
var link = document.querySelector('link[rel="import"]'); if(!link) return; var content = link.import; var child = content.querySelector('.list-item'); var host = document.querySelector('#host'); host.appendChild(child.cloneNode(true)); } showTemplate(); showTemplate(); showTemplate(); ´ÙÀ½ ¶óÀÎÀ» ÀÌ¿ëÇϸé ÀÚ½ÄÀÇ ¿ä¼Òµé¿¡ Á¢±Ù ÇÒ¼ö ÀÖ°Ô µÈ´Ù. var link = document.querySelector('link[rel="import"]'); if(!link) return; var content = link.import; ÀÚ½Ä ¿ä¼Ò '.list-item'¸¦ °¡Á®¿Í¼ ºÎ¸ð '#host'¿¡ Ãß°¡ÇÑ´Ù. var child = content.querySelector('.list-item'); var host = document.querySelector('#host'); host.appendChild(child.cloneNode(true)); ÀÚ½ÄÀ» 3¹ø Ãß°¡ÇÑ´Ù. showTemplate(); °á°ú) Include Html Å×½ºÆ® Include Html Å×½ºÆ® Include Html Å×½ºÆ® ´Ù¿î·Îµå: ¸ÞÀÎ HTML ÆÄÀÏ : import_test.html ÀÚ½Ä HTML ÆÄÀÏ : box.html webcomponentsjs-0.7.12.zip ÂüÁ¶) https://docs.microsoft.com/en-us/skype-sdk/websdk/lib/webcomponentsjs/readme https://www.codementor.io/ayushgupta/vanilla-js-web-components-chguq8goz https://www.html5rocks.com/ko/tutorials/webcomponents/imports/ |