์๋
ํ์ธ์
์ฌ๋ฌ ํ์ ๋ง๋ค๊ฑฐ๋ html์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
?
๋ค์์ https://sweetalert.js.org/docs/#content๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ ํดํน์ ๋๋ค
var span = document.createElement("span");
span.innerHTML='abc<br>efg'
swal({
content: span,
});
๋ ๋์ ๋ฐฉ๋ฒ์ด ์๋ค๊ณ ํ์ ํฉ๋๋ค.
์ง๊ธ์ @simon1tan ์ ๋ฐฉ์์ด ๊ฐ ๊ธธ์ด์ง๋ง ์ค ๋ฐ๊ฟ์ ์ถ๊ฐํ๋ ๊ฒ๊ณผ ๊ฐ์ ๊ฐ๋จํ ์์
์๋ ์ฝ๊ฐ ์ง๋ฃจํ๋ค๋ ๋ฐ ๋์ํฉ๋๋ค. ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ SweetAlert๊ฐ ํ
์คํธ ์ต์
์์ \n
๋ฌธ์๋ฅผ <br>
ํ๊ทธ๋ก ์๋ ๊ต์ฒดํ์ฌ ์ฌ๋๋ค์ด ๋ค์๊ณผ ๊ฐ์ด ์์ฑํ ์ ์๋๋ก ํ๋ ๊ฒ์
๋๋ค.
swal("Hello\nthere!")
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ์ถ์ ์ฌ๋์ด ์์ผ๋ฉด(๋งค์ฐ ๊ฐ๋จํด์ผ ํจ) ํ ๋ฆฌํ์คํธ๋ฅผ ๋ณด๋ด์ฃผ์ธ์!
HTML ์์๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ฐพ๋ ๊ฒ์ด ์ด๋ ค์ ์ต๋๋ค. ๊ทํ์ ํดํน์ด ์ ์๊ฒ ๋์์ด ๋์์ต๋๋ค. ์ ๋ง ๊ฐ์ฌํฉ๋๋ค!
PD: "\n"์ด ์๋ํ์ง ์์ต๋๋ค. ์ค ๋ฐ๊ฟ์ด ๋์ง ์์ต๋๋ค.
๋๋ ์๋์ผ๋ก ์ํฉ์ด ์ข์ง ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ค๋ฅธ ์ต์ ์ด ๋ ๋์ ๊ฒ ๊ฐ์ต๋๋ค. ์
html์ ์ฌ์ฉํ์ฌ "
"
์ค์({
์ ๋ชฉ: '์ค๋ฅ',
html: '์๋ ํ์ธ
asdasdasas' ,
showConfirmButton: ์ฐธ,
showCloseButton: ์ฐธ,
})
์๋
ํ ๊ณ์ธ์
const lines = ['๋น์ ์ ์ฐ๋ฆฌ์๊ฒ ๋งค์ฐ ์ค์ํฉ๋๋ค. ๋ฐ์ ๋ชจ๋ ์ ๋ณด๋ ํญ์ ๊ธฐ๋ฐ๋ก ์ ์ง๋ฉ๋๋ค.', '๋น์ ์ ๋ฉ์์ง๋ฅผ ๊ฒํ ํ๋ ๋๋ก ์ฐ๋ฝ์ ๋๋ฆฌ๊ฒ ์ต๋๋ค.', ''+contact_email+'๋ก ์ด๋ฉ์ผ์ ๋ณด๋์ต๋๋ค. , ๋น ๋ฅธ ๋ต๋ณ์ ์ํด ํ์ธํด์ฃผ์ธ์.'];
swal('๋ฌธ์ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!',lines.join('\n\n'),'success');
// ๋๋ฅผ ์ํด ์ผํ๋ค!
const lines = ['You are very important to us, all information received will always remain confidential.', 'We will contact you as soon as we review your message.', 'We have sent an email to you at '+contact_email+' , Please check it for quick response.'];
swal('Thank you for contacting us!',lines.join('\n\n'),'success');
๋ด ๊ฒฝ์ฐ์๋ ํ ์คํธ๋ฅผ ๋ฎ๊ธฐ ์ํด ์ถ๊ฐ๋ div ํ๊ทธ๊ฐ ์๋ํฉ๋๋ค.
origina: Line0<br />Line1<br /> [not working]
after: <div>Line0<br />Line1<br /></div> [working fine]
swal({
title: 'Mt Title',
html: '<div>Line0<br />Line1<br /></div>',
});
swal({
buttons: ["Wait ", "Add Details"],
html: true,
text: "Text one .\n Text 2.\n Text 3."
})
์ฌ๊ธฐ ํด๊ฒฐ์ฑ
์ด ์์ต๋๋ค. ๋ฐ์์์ ์๋ฒฝํ๊ฒ ์๋ํฉ๋๋ค. ์ฆ๊ธฐ๋ค
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ค์์ https://sweetalert.js.org/docs/#content๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ ํดํน์ ๋๋ค
๋ ๋์ ๋ฐฉ๋ฒ์ด ์๋ค๊ณ ํ์ ํฉ๋๋ค.