๋ถํธ์คํธ๋ฉ CDN(Content Delivery Network)์ ํฌํจํ๋ฉด ๋ถํธ์คํธ๋ฉ์ ์ง์ ๋ค์ด๋ก๋ํ๊ณ ํธ์คํ ํ์ง ์์๋ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.slim.min.js"></script>
<!-- Popper JS -->
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
<script>
const dataArr = [
{"panHeading": "BLACK FRIDAY DEA 1", "panImage":"./images/1.jpg", "panFooter":"Buy 50 mobiles and get a gift car"},
{"panHeading": "BLACK FRIDAY DEA 2", "panImage":"./images/2.jpg", "panFooter":"Buy 50 mobiles and get a gift car"},
{"panHeading": "BLACK FRIDAY DEA 3", "panImage":"./images/3.jpg", "panFooter":"Buy 50 mobiles and get a gift car"},
{"panHeading": "BLACK FRIDAY DEA 4", "panImage":"./images/4.jpg", "panFooter":"Buy 50 mobiles and get a gift car"},
{"panHeading": "BLACK FRIDAY DEA 5", "panImage":"./images/5.jpg", "panFooter":"Buy 50 mobiles and get a gift car"},
{"panHeading": "BLACK FRIDAY DEA 6", "panImage":"./images/1.jpg", "panFooter":"Buy 50 mobiles and get a gift car"}
];
const rowTmp = `
<div class="row">
<%
dataArr.forEach(function(item, idx) {
console.log(idx);
%>
<div class="col-sm-4">
<div class="panel panel-primary">
<div class="panel-heading"><%=item.panHeading %></div>
<div class="panel-body"><img src=<%=item.panImage %> class="img-responsive" style="width:100%" alt="Image"></div>
<div class="panel-footer"><%=item.panFooter %></div>
</div>
</div>
<%
}); // end of forEach %>
</div>
`;
var compiled = _.template(rowTmp);
var html = compiled({dataArr:dataArr});
console.log(html);
document.getElementById("middle").innerHTML = html;
</script>
๋ถํธ์คํธ๋ฉ ๋ ์ด์์ ํ ํ๋ฆฟ์ ์ฌ์ฉํ์ฌ ๋ฐ๋ณต๋๋ html ๋ถ๋ถ์ ์คํฌ๋ฆฝํธ๋ก ๋ฐ๊พธ๊ณ ๋ฐ์ดํฐ๋ฅผ ์์ ํด๋ณด์๋ค.
๋ถํธ์คํธ๋ฉ ํ
ํ๋ฆฟ์์ ํ
์คํธ, ๋ฐ์ดํฐ ๋ฑ์ ์์ ํ์ฌ ๊ฐ์ธ ์น์ฌ์ดํธ๋ฅผ ์ฝ๊ฒ ๋ง๋ค ์ ์๋ค.
https://webkit2023.web.app/
์ ์ ์ฌํ ์ผ์ ๋์ ๊ณํ ์น ์ฌ์ดํธ ํ๋ก์ ํธ๋ฅผ ํ ๊ฒฝํ์ด ์๋ค. ์ด ๋ ํ๋ก ํธ์ค๋๋ฅผ ๋ด๋นํ์ฌ ๊ฐ๋ฐํ์๋๋ฐ, ์ ๋ถํธ์คํธ๋ฉ์ ์ฌ์ฉํ์ง์์์๊น?๐ ๋์์ธ์ ์์๋ฅผ ๋ง์ด ๊ณ ๋ คํ์ง ์๊ณ ์์ CSS์ ์ฌ์ฉํ์ฌ ๊ตฌํํ์๋ค. ๋ฌผ๋ก ๊ทธ ๋์ ์นํผ๋ธ๋ฆฌ์ฑ๊ณผ ๊ด๋ จ๋ ๊ณต๋ถ๋ ์ ๋๋ก ๋์๋ค. ๊ทธ๋ ์ง๋ง ๋ถํธ์คํธ๋ฉ์ ์ฌ์ฉํ๋ค๋ฉด ๋์ฑ ๋ ์์ฑ๋ ์๋ ์น์ฌ์ดํธ๋ฅผ ๋ง๋ค ์ ์์์ ๊ฒ์ด๋ค. ๋น์์๋ ๊ธฐ๋ฅ ๊ตฌํ์ ๋ฐ๋น ๋์์ธ์ ์์๋ ์ ๊ฒฝ์ ๋ง์ด ๋ชป ์ผ๋๋ฐ ๋ถํธ์คํธ๋ฉ์ ์ตํ๋ค๋ฉด ์ข์์ ๊ฒ ๊ฐ๋ค.๐ค๐ฅถ