๋ชฉ์ฐจ
์ค๋๋ ์ญ์ ๋ฏธ๋์ ๋ด๊ฐ ๋ณด๊ธฐ ์ํด ๊ธฐ๋ก์ ๋จ๊ธด๋ค.
๋์ ์๋ฆฌ๋จผํธ์ feather ์์ด์ฝ ์ถ๊ฐ ๐
feather ์์ด์ฝ์ ์ฒ์ ์ฌ์ฉํด๋ด์ ์ฝ์งํ ๊ฒ ์ ํ ์๋์๋๋ฐ.. ์ฝ์ง์ ์ข ํ๋ค.
์ฐ์ ์๋์ฒ๋ผ feather.js๋ฅผ ๋ถ๋ฌ์จ ๋ค์ ๋ง๋ ์๋ฆฌ๋จผํธ์ data-feather๋ฅผ ๋ถ์ฌ ํ script์์ feather.replace()๋ฅผ ํธ์ถํ๋ฉด ์์ด์ฝ์ด ์ด์๊ฒ ์๊ธด๋ค.
๋ฌผ๋ก ์์ด์ฝ์ data-feather์ ํฌํจ๋ ๊ฒ๋ง ๋๋ค.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>feather test</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body>
<div id="test-div">
<span id="feather-icon" data-feather="home" class="align-text-bottom"></span>
home
</div>
<script>
feather.replace();
</script>
</body>
</html>
๋์ ์๋ฆฌ๋จผํธ์ feather๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ์ ์๋์ฒ๋ผ ํ๋ฉด ๋๋ค.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>feather test</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body>
<div id="test-div"></div>
<script>
$(document).ready(function () {
let testFeather = "";
testFeather += '<span id="feather-icon" data-feather="home" class="align-text-bottom"></span>home';
$("#test-div").html(testFeather);
feather.replace();
});
</script>
</body>
</html>
๋ด ๊ฒฝ์ฐ๋ ์๋์ฒ๋ผ ํด์ ์์ด์ฝ์ผ๋ก ๋ณํ๋์ง ์์์๋ค.
๋น์ฐํ ์๋ฆฌ๋จผํธ๋ฅผ ๊ทธ๋ ค์ฃผ๋ ์คํฌ๋ฆฝํธ ๋ฒ์์์์ feather.replace()๋ฅผ ํด์ผ ํ๋ค.
reference: https://github.com/feathericons/feather/issues/758
How to add feather icons to dynamic elements? · Issue #758 · feathericons/feather
I have a code like: var resultsHtml = ''; results.forEach(function(res) { resultsHtml += '<li>' + '<a class="list-link" href="#">' + '<...
github.com

'IT > development' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[bootstrap] bootstrap modal์ฐฝ ๋์ฐ๊ธฐ (2) | 2022.12.08 |
---|---|
[spring] @ControllerAdvice, @ExceptionHandler๋ฅผ ์ด์ฉํ ์์ธ์ฒ๋ฆฌ (0) | 2022.12.04 |
[WAS] apache tomcat 8.0 ์ด์ ver ๋ค์ด๋ก๋... (0) | 2022.11.30 |
[Spring]RequestMapping์ ๋ณํ (0) | 2022.11.30 |
[Spring]@ModelAttribute ์ด๋ ธํ ์ด์ (0) | 2022.11.30 |
๋๊ธ