๐Ÿฅฆ๋ธŒ๋กœ์ปฌ๋ฆฌ๐Ÿฅฆ ํ”„๋กœ์ ํŠธ 5์ผ์ฐจ

Maria Kimยท2021๋…„ 12์›” 4์ผ
1
post-custom-banner

1๊ฐœ์˜ sprint์˜ ๋! ๊ธˆ์š”์ผ!! ํ•œ ์ฃผ๊ฐ€ ๋๋‚ฌ๋‹ค!

์˜ค๋Š˜์€ ํŒ€๊ณผ ํ•จ๊ป˜ LOVE ๋ฉด๋‹ด์„ ํ•˜๋ฉฐ ๋งŽ์€ ๋ถ€๋ถ„์„ ๋Š๊ผˆ์ง€๋งŒ
์ฒซ ํ‚ค์Šค ์ฒ˜๋Ÿผ ์ด๋ฒˆ ํ”„๋กœ์ ํŠธ๊ฐ€ ๋‹ค์‹œ๋Š” ์˜ค์ง€ ์•Š์„, ๊ณ„์† ๊ธฐ์–ต์— ๋‚จ์„
๋‚ด ์ฒซ!!ํ”„๋กœ์ ํŠธ!๋ผ๋Š” ์ ์ด ์ฐธ ์™€๋‹ฟ์•˜๋‹ค.

๊ทธ๋ ‡๊ฒŒ ์ƒ๊ฐํ•˜๋‹ˆ ๋ญ”๊ฐ€ ๋” ์• ํ‹‹ํ•˜๊ณ  ๋” ์ž˜ ์†Œ์ค‘ํžˆ ๋‹ค๋ค„์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค.
๋” ์†Œ์ค‘ํžˆ ํ•ด์•ผ์ง€ ๋Œ์•„๋ดค์„ ๋•Œ ์–ธ์ œ๋‚˜ ๊ธฐ์–ตํ•˜๊ณ  ์‹ถ์€ ์ˆœ๊ฐ„์œผ๋กœ ๋‚จ๊ฒŒ ํ•ด์•ผ์ง€.
๊ทธ๋Ÿฌ๋‹ˆ ๋” ์ฆ๊ฒ๊ฒŒ ํ–‰๋ณตํ•˜๊ฒŒ ํ™”์ดํŒ…ํ•˜์ž!!

ํšŒ๊ณ  ๋ฏธํŒ…

๋‚˜์˜ ํšŒ๊ณ  : ๋ฒŒ์จ ์ผ์ฃผ์ผ์ด ์ง€๋‚ฌ๋‹ค๋‹ˆ, ๋ฏฟ๊ธฐ์ง€ ์•Š๋Š”๋‹ค. ๋” ์ฆ๊ธฐ๋ฉด์„œ ํ•ด์•ผ๊ฒ ๋‹ค!

ํŒ€์›๋“ค์˜ ํšŒ๊ณ 

  • ๋Œ€ํ™”๋ฅผ ํ•˜์ž
  • ์›”, ํ™”์š”์ผ๊นŒ์ง€๋งŒ ํ•ด๋„ ์•„์ง ์—ฌ์œ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ, ์‹œ๊ฐ„์ด ์ •๋ง ๋นจ๋ฆฌ๊ฐ„๋‹ค
  • ๋‚ ์งœ๋Š” ์ง€๋‚˜๊ฐ€๋Š”๋ฐ, ์ •์ž‘ ์ฝ”๋“œ๋Š” ํ•œ ๊ธ€์ž๋„ ์ณ๋‚ด์ง€ ๋ชปํ•ด์„œ ์ดˆ์กฐํ•จ์ด ์ค‘์ฒฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ตœ๋Œ€ํ•œ ์นจ์ฐฉํ•˜๊ฒŒ ๋งˆ์Œ์„ ๋จน๊ณ , ํŒ€์›๊ณผ ์ตœ๋Œ€ํ•œ ํ˜„ ์ƒํƒœ๋ฅผ ์—…๋Žƒํ•˜๊ณ  ์†Œํ†ตํ•ด๊ฐ€๋ฉด์„œ ์ œ๊ฐ€ ๋งก์€ ๋ถ€๋ถ„์„ ํ•ด๋‚ด๊ณ ์ž ๋…ธ๋ ฅํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒด๋ ฅ์ ์œผ๋กœ ์ง€์น˜๋Š” ๋ถ€๋ถ„์€ ์—†์ง€๋งŒ, ์‹ฌ์ ์œผ๋กœ ๋” ๋งค๋ชฐ๋˜์ง€ ์•Š๋„๋ก ํ•ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค.
  • ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด๋นจ๋ฆฌ์ง€๋‚˜๊ฐ€๋Š”๊ฒƒ๊ฐ™๊ณ  ์•ž์œผ๋กœ ํ•ด์•ผํ• ๊ฒƒ๋“ค์ด ๋งŽ์€๋ฐ ์กฐ๊ธˆ์€ ๋ง‰๋ง‰ํ•˜๋‹ค. ๊ทธ๋ž˜๋„ ์—ด์‹ฌํžˆ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹น

์˜ค๋Š˜์˜ ์„ฑ์žฅ

  • ๋‹ค์–‘ํ•œ page์—์„œ modal ์„ ์‚ฌ์šฉํ•ด ์•Œ๋ฆผ, ํŒ์—…์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์ปดํฌ๋„ŒํŠธํ™” ํ–ˆ๋‹ค.
  • Modal ๋‚ด์šฉ์˜ ํฌ๊ธฐ๋Š” ์œ ๋™์ ์ด์—ฌ์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— Wrapper๋ฅผ ๋Š๋‚Œ์œผ๋กœ ๋งŒ๋“ค์—ˆ๋‹ค.
  • Modal ์ปดํฌ๋„ŒํŠธ๊ฐ€ ํ•˜๋Š” ์—ญํ•  :
    • ๋ฐฐ๊ฒฝ ํด๋ฆญ๋˜๋ฉด ๋‹ซํžˆ๊ฒŒ
    • ๋ฐฐ๊ฒฝ ์–ด๋‘ก๊ฒŒ
    • ์ƒ์ž ๋ฐฐ๊ฒฝ ํฐ์ƒ‰
    • ํ™”๋ฉด์— ์ „์ฒด ์ฐจ์ง€ํ•˜๊ธฐ

js ํŒŒ์ผ

function Modal({ children, closeModal }) {
  const modalContent = useRef();

  const clickOutside = e => {
    if (!modalContent.current.contains(e.target)) {
      closeModal();
    }
  };

  return (
    <div className="modal" onClick={clickOutside}>
      <div className="modalContent" ref={modalContent}>
        {children}
      </div>
    </div>
  );
}

export default Modal;

scss ํŒŒ์ผ

.modal {
  @include flexCenter;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: rgba($color: #000000, $alpha: 0.3);

  .modalContent {
    background-color: $bg-white;
    border-radius: 15px;
  }
}
  • ์ด์ „ ์ฝ”๋“œ
  • modal ์‚ฌ์šฉํ•˜๋Š” ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ ๋ถ€๋ถ„
      {isCartModalOpen && (
        <CartModal
          setCartInfo={setCartInfo}
          product={cartInfo}
          setIsCartModalOpen={setIsCartModalOpen}
        />
  • modal๋กœ ์‚ฌ์šฉ๋˜์—ˆ๋˜ CartModal

function CartModal({ product, setCartInfo, setIsCartModalOpen }) {
  const modalContent = useRef();
  const [quantity, setQuantity] = useState(1);
  const { name, price } = product;

  const closeModal = () => {
    setCartInfo({});
    setIsCartModalOpen(false);
  };

  const addQuantity = () => {
    setQuantity(quantity + 1);
  };

  const clickOutside = e => {
    if (!modalContent.current.contains(e.target)) {
      closeModal();
    }
  };

  // TODO : ์žฅ๋ฐ”๊ตฌ๋‹ˆ ์ถ”๊ฐ€ ์‹œ fetch ํ•˜๊ธฐ
  const addProductToCart = () => {
    closeModal();
  };

  return (
    <div className="modal" onClick={clickOutside}>
      <div className="modalContent" ref={modalContent}>
        <div className="top">
          <div className="productName">{name}</div>
          <div className="productDetail">
            <div className="price">{Number(price).toLocaleString()}์›</div>
            <div className="quantityContainer">
              <button className="down" onClick={removeQuantity}>
                -
              </button>
              <span className="quantity">{quantity}</span>
              <button className="up" onClick={addQuantity}>
                +
              </button>
            </div>
          </div>
        </div>
        <div className="bottom">
          <div className="totalContainer">
            <h3 className="totalText">ํ•ฉ๊ณ„</h3>
            <h2 className="total">
              {Number(quantity * price).toLocaleString()}
              <span className="unit">์›</span>
            </h2>
          </div>
          <div className="btns">
            <button className="cancel btn" onClick={closeModal}>
              ์ทจ์†Œ
            </button>
            <button className="addToCart btn" onClick={addProductToCart}>
              ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋‹ด๊ธฐ
            </button>
          </div>
        </div>
      </div>
    </div>
  );
}
  • ๋ณ€๊ฒฝ๋œ ์ฝ”๋“œ
    - ๋Œ€์‹  Cartmodal ์•ˆ์—์„œ ๋งŒ๋“ค๋˜ modal ๋‹ซํž ๋•Œ ์ผ์–ด๋‚˜์•ผ ํ•˜๋Š” ๋กœ์ง์„ ๋‹ด์€ closeModal ํ•จ์ˆ˜๋ฅผ Modal ์„ ์‚ฌ์šฉํ•˜๋Š” ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ ๋งŒ๋“ค์–ด Modal ์ปดํฌ๋„ŒํŠธ์™€ Modal ์•ˆ ์ƒ์ž ๋ถ€๋ถ„์— ๋“ค์–ด๊ฐˆ CartModal ์— closeModal ํ•จ์ˆ˜๋ฅผ ๋„ฃ์–ด์ค˜์•ผ ํ•จ.
    • Cartmodal ์•ˆ์— Modal ๋ฐฐ๊ฒฝ, Modal ์ƒ์ž ์— ๋Œ€ํ•œ ๋ถ€๋ถ„, Modal Outside click ์‹œ ๋‹ซํžˆ๊ฒŒ ํ•˜๋Š” ๋กœ์ง ์—†์–ด์ง
  • modal ์‚ฌ์šฉํ•˜๋Š” ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ ๋ถ€๋ถ„
      {isCartModalOpen && (
        <Modal closeModal={closeModal}>
          <CartModal closeModal={closeModal} product={cartInfo} />
        </Modal>
      }
  • modal๋กœ ์‚ฌ์šฉ๋˜์—ˆ๋˜ CartModal
function CartModal({ product, closeModal }) {
  const [quantity, setQuantity] = useState(1);
  const { name, price } = product;

  const addQuantity = () => {
    setQuantity(quantity + 1);
  };

  // TODO : ์žฅ๋ฐ”๊ตฌ๋‹ˆ ์ถ”๊ฐ€ ์‹œ fetch ํ•˜๊ธฐ
  const addProductToCart = () => {
    closeModal();
  };

  return (
    <div className="cartModal">
      <div className="top">
        <div className="productName">{name}</div>
        <div className="productDetail">
          <div className="price">{Number(price).toLocaleString()}์›</div>
          <div className="quantityContainer">
            <button className="down" onClick={removeQuantity}>
              -
            </button>
            <span className="quantity">{quantity}</span>
            <button className="up" onClick={addQuantity}>
              +
            </button>
          </div>
        </div>
      </div>
      <div className="bottom">
        <div className="totalContainer">
          <h3 className="totalText">ํ•ฉ๊ณ„</h3>
          <h2 className="total">
            {Number(quantity * price).toLocaleString()}
            <span className="unit">์›</span>
          </h2>
        </div>
        <div className="btns">
          <button className="cancel btn" onClick={closeModal}>
            ์ทจ์†Œ
          </button>
          <button className="addToCart btn" onClick={addProductToCart}>
            ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋‹ด๊ธฐ
          </button>
        </div>
      </div>
    </div>
  );
}

outside click (Event.stopPropagation() ์“ฐ์ง€ ์•Š๋Š” ๋ฐฉ๋ฒ•)

  • ์šฉ์–ด ์„ค๋ช…
    • closeModal : Modal ๋‹ซ์„ ๋•Œ ํ•ด์•ผํ•˜๋Š” ๋กœ์ง์„ ์ ์€ ํ•จ์ˆ˜
    • modal ๋ฐฐ๊ฒฝ -> ์–ด๋‘์–ด์ง„ modal ์ƒ์ž ๋ฐ– ๋ถ€๋ถ„
    • modal ์ƒ์ž -> ๋‚ด์šฉ์ด ๋“ค์–ด ์žˆ๋Š” ํฐ์ƒ‰ ๋ถ€๋ถ„
    • modalBackground -> modal ๋ฐฐ๊ฒฝ ์š”์†Œ
    • modalContent -> modal ์ƒ์ž ์ œ์ผ ์ตœ์ƒ์œ„ ์š”์†Œ

1๋ฒˆ์งธ ๋ฐฉ๋ฒ•

  • ๋กœ์ง
    • modal ๋ฐฐ๊ฒฝ์— ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ์–ด -> ๋ฐฐ๊ฒฝ์ด ํด๋ฆญ๋˜๋ฉด modal์ด ๋‹ซํžˆ๊ฒŒ ํ•จ
    • modal ์ƒ์ž ์•ˆ์—์„œ ํด๋ฆญ๋˜๋ฉด ๋‹ซํžˆ์ง€ ์•Š๋„๋ก, modalContent์— ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ์–ด modalContent์ด ํด๋ฆญ๋˜๊ฑฐ๋‚˜ modalContent ๋‚ด๋ถ€์—์„œ ํด๋ฆญ๋˜์–ด ๋ฒ„๋ธ”๋ง ๋˜์–ด modalContent๊นŒ์ง€ ๋„๋‹ฌํ•œ ํด๋ฆญ ์ด๋ฒคํŠธ๊ฐ€ ๋” ์ด์ƒ ์ƒ์œ„ ์š”์†Œ๋กœ ๋ฒ„๋ธ”๋ง ๋˜์ง€ ์•Š๋„๋ก stopClickPropagation ๋ฅผ ์ ์šฉํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋„ฃ์Œ
  • ๋ฌธ์ œ
    • stopClickPropagation ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฒคํŠธ์— ๋Œ€ํ•œ ๋ฒ„๋ธ”๋ง์„ ๋ง‰์•„ ๋‚˜์ค‘์— ์ฝ”๋“œ๊ฐ€ ๋” ๋ณต์žกํ•ด ์ง€๋งŒ ์•„๋ž˜ ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋‹ค๋ฅธ ๊ณณ์—์„œ ํ™•์ธํ•˜์ง€ ๋ชปํ•ด ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ์Œ. ์ •~~~๋ง ๋ฐฉ๋ฒ•์ด ์—†๋‹ค๋ฉด ์‚ฌ์šฉํ•ด์•ผ ํ•˜์ง€๋งŒ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
function Modal() {
  const stopClickPropagation = e => {
    e.stopPropagation();
  }
  return (
     <div className="modalBackground" onClick={closeModal}>
      <div className="modalContent" onClick={stopClickPropagation}>

2๋ฒˆ์งธ ๋ฐฉ๋ฒ•

  • ์ด์ „๋ณด๋‹ค ๋‚˜์•„์ง„ ๋ถ€๋ถ„
    • stopPropagation๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋‹ค.
    • ๋ฒ„๋ธ”๋ฆญ ๋ง‰๊ธฐ ํƒˆ์ถœ!
  • ๋กœ์ง
    • modalBackground์— ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ๊ณ  e.target.closest ๋ฅผ ์‚ฌ์šฉํ•ด
    • ์ž๊ธฐ ์ž์‹ ์„ ํฌํ•จํ•ด์„œ ์ƒ์œ„๋กœ ์ถœ๋ฐœํ•ด ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๋ถ€๋ชจ์š”์†Œ์— modalContent ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ฒŒ ํ•จ
    • ๋ฐฐ๊ฒฝ ๋ถ€๋ถ„์€ ์•„๋ž˜์— modalContent ๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— false๊ฐ€ ๋‚˜์˜ฌ ๊ฒƒ์ด๊ณ  modal ์ƒ์ž ์•ˆ์—์„œ๋Š” ๋ฌด์กฐ๊ฑด ์ƒ์œ„์— modalContent๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— true๊ฐ€ ๋‚˜์˜ฌ ๊ฒƒ์ž„
      - Element.closest() ?! ๊ฐ€์žฅ ๊ฐ€๊น๊ฒŒ ์กฐ๊ฑด์— ๋งŒ์กฑํ•œ ๋ถ€๋ชจ ์š”์†Œ๊ฐ€ ๋ฐ˜ํ™˜, ์—†์œผ๋ฉด null
      [MDN] Element.closest()
  • ๋ฌธ์ œ
    • className๋“ค์ด ๋ณ€๊ฒฝ์ด ๋˜์—ˆ์„ ๋•Œ ๋“ฑ ์œ ์—ฐํ•œ ๋Œ€์ฒ˜๊ฐ€ ์–ด๋ ค์›€, ๋„ˆ๋ฌด ์ œํ•œ์ ์ธ ์ ์šฉ์ด ๋จ.
function Modal() {
  const clickOutside = e => {
    if (!e.target.closest('.modalContent')) {
            closeModal();
    }
  return (
      <div className="modalBackground" onClick={clickOutside}>
        <div className="modalContent">

3๋ฒˆ์งธ ๋ฐฉ๋ฒ•

  • ์ด์ „๋ณด๋‹ค ๋‚˜์•„์ง„ ๋ถ€๋ถ„
    - contains method๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒŒ ์ข€ ๋” ์˜๋ฏธ์ƒ ์ ํ•ฉํ•˜๊ณ , ๋งˆํฌ์—…, className ๋“ฑ์ด ๋ณ€๊ฒฝ๋์„ ๋•Œ ์ข€ ๋” ์œ ์—ฐํ•˜๊ฒŒ ๋Œ€์ฒ˜ํ•  ์ˆ˜ ์žˆ์Œ
    [MDN]Node.contains()
  • ๋กœ์ง
    • modal ์ƒ์ž ๋ถ€๋ถ„์— ref ๋ฅผ ๋‹ฌ์Œ
    • modal ๋ฐฐ๊ฒฝ ๋ถ€๋ถ„์— ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ์–ด ์•„๋ž˜์—์„œ ์ผ์–ด๋‚˜๋Š” ๋ชจ๋“  ์ด๋ฒคํŠธ๋ฅผ ์ธ์‹ํ•˜๊ฒŒ ํ•จ
    • ์ž์‹  ํฌํ•จ ์•„๋ž˜์—์„œ ์ผ์–ด๋‚˜๋Š” ์ด๋ฒคํŠธ ์ค‘ ์ด๋ฒคํŠธ๊ฐ€ ์ผ์–ด๋‚˜๋Š” target ์ด ์ƒ์ž ์•ˆ์— ์žˆ์œผ๋ฉด modal์ด ๋‹ซํžˆ์ง€ ์•Š๊ณ 
    • ์™ธ๋ถ€์— ์žˆ์œผ๋ฉด ๋‹ซํž˜
function Modal() {
  const modalContent = useRef();
  
  const clickOutside = e => {
    if (!modalContent.current.contains(e.target)) {
      closeModal();
    }
  };
  return (
    <div className="modalBackground" onClick={clickOutside}>
      <div className="modalContent" ref={modalContent}>

์˜ค๋Š˜์˜ ์„ฑ์žฅ

  • absolute ์™€ fixed์˜ ์ฐจ์ด
    • fixed๋ฅผ ์ž˜ ์‚ฌ์šฉ ํ•  ์ผ์ด ์—†๋‹ค๋ณด๋‹ˆ ๋Œ€๋ถ€๋ถ„ absolute ๋ฅผ ์‚ฌ์šฉํ–ˆ์—ˆ๋‹ค.
      ๊ทธ๋ž˜์„œ modal๋ฅผ ๋งŒ๋“ค ๋•Œ๋„ absolute๋ฅผ ์‚ฌ์šฉํ–ˆ์—ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์—ˆ์–ด์„œ ๋ฌธ์ œ์ ์„ ๋ชป ์ฐพ์•˜๋‹ค๊ฐ€
      Nav์™€ Footer๋ฅผ ๋‚ด ์ปดํฌ๋„ŒํŠธ์™€ ๋ถ™์ด๋‹ˆ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค.
      Main ๋ถ€๋ถ„์—๋งŒ Modal์ด ์ฐจ์ง€ ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ๊ฐ€... ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹
      ๊ทธ๋•Œ ์•„?! ํ™”๋ฉด์„ ๊ณ ๋ คํ•œ๋‹ค๋ฉด fixed๊ฐ€ ์•„๋‹Œ๊ฐ€ ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ ์ƒ๊ฐ์„ ํ•˜์—ฌ ๋ณ€๊ฒฝํ–ˆ๋‹ค.
      ์ด๋ฅผ ๊ณ„๊ธฐ๋กœ ์–ด๋–ป๊ฒŒ absolute์™€ fixed์˜ ์–ธ์ œ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”์ง€ ์ œ๋Œ€๋กœ ๋ชธ์†Œ ๋Š๋‚€ ํ•˜๋ฃจ์˜€๋‹ค.
  • ์ˆ˜๋Ÿ‰์„ ์ˆ˜์ •ํ•˜๋Š” ๋ถ€๋ถ„

    - ์ด ์ˆ˜๋Ÿ‰์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ถ€๋ถ„์„ ๋‹ค ๋งŒ๋“ค๊ณ  ๋ฟŒ๋“ฏํ•ด์„œ ์‹œ์—ฐ์„ ํ•˜๋Š”๋ฐ ์–ด๋จธ๋‚˜ ใ…‹ใ…‹ใ…‹ใ…‹ ๋ฉ˜ํ† ๋‹˜์ด 1์„ ํด๋ฆญํ•˜๋Š” ์ˆœ๊ฐ„ ์–ด?! ์ž˜๋ชป๋จ์„ ๋Š๊ผˆ๋‹ค.
    - 1 ๋ถ€๋ถ„์„ input์ด ์•„๋‹Œ span ์œผ๋กœ ๋งŒ๋“  ๊ฒƒ์ด ์•„๋‹ˆ๊ฒ ๋Š”๊ฐ€ ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹
    - ์ˆ˜๋Ÿ‰ ๋ณ€๊ฒฝ์„ ๋” ์ž์œ ๋กญ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹น์—ฐํžˆ input ์œผ๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ค์–ด์ค˜์•ผ ํ•œ๋‹ค.(๋‚˜๋„ ์‚ฌ์‹ค ํ•œ ๊ฐœ์”ฉ๋งŒ ๋ณ€๊ฒฝ๋˜๋Š” ๋ฒ„ํŠผ๋งŒ ๋˜๋Š” ๊ฒƒ์„ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€ ๋‹ต๋‹ตํ–ˆ๋˜ ์ ์ด ์žˆ๋‹ค.)
    - ์‚ฌ์šฉ์ž๋ฅผ ๋” ๊ณ ๋ ค ํ•˜์ž! ๋” ๊ณ ๋ฏผ์„ ๋งŽ์ด ํ•˜์ž!!!
  • ์ˆ˜๋Ÿ‰์ด ๋ช‡๊นŒ์ง€ ๋‚ด๋ ค๊ฐˆ ์ˆ˜ ์žˆ๋Š”๊ฐ€?
    • ๋‚˜๋Š” ๋‹น์—ฐํžˆ 1๊นŒ์ง€๋งŒ ๋˜๊ฒŒ ํ•˜๋„๋ก ํ–ˆ๋Š”๋ฐ
    • ์ปค๋จธ์Šค ์‚ฌ์ดํŠธ๋“ค์„ ๋Œ์•„๋ณด๋‹ˆ 0๊นŒ์ง€๋„ ๋˜๋„๋กํ•˜๋Š”๊ฒƒ์ด ์•„๋‹Œ๊ฐ€?!
    • ์™œ ๊ทธ๋Ÿฐ๊ฐ€ ํ–ˆ๋”๋‹ˆ ์ปดํฌ๋„ŒํŠธ๋กœ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•˜๊ณ  ์„ ํƒ์‚ฌํ•ญ์ด ์—ฌ๋Ÿฌ ๊ฐœ์ธ ๊ฒฝ์šฐ 0๋„ ๋˜๋„๋ก ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
    • ๊ทธ๋ž˜์„œ ์ฃผ๋ฌธ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ ์ „์ฒด์ ์œผ๋กœ ์ตœ์†Œ 1๊ฐœ๊ฐ€ ์ฃผ๋ฌธ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋กœ์ง์ด ์žˆ์–ด 0์„ ์ฃผ๋ฌธ ๋ชปํ•˜๊ฒŒ ํ•˜๋Š” ๋ฐฉ์‹์ด์—ˆ๋‹ค.
profile
Frontend Developer, who has business in mind.
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€