reactjs와 jQuery를 인터페이스하는 것 : 종합 가이드
npm install jquery --save npm i --save-dev @types/jquery
npm install jquery --save npm i --save-dev @types/jquery
Step 1: Understanding the Accordion
import React, { useState } from 'react'; const Accordion = () => { const [activeSection, setActiveSection] = useState(null); const handleHeadClick = (e) => { const section = e.target.parentElement; if (section === activeSection) { setActiveSection(null); } else { setActiveSection(section); } }; return (In its HTML form, an accordion consists of multiple sections, each containing a header and a collapsible body. jQuery는 이벤트 리스너를 사용하여 이러한 요소를 동적으로 조작 할 수 있습니다. line.{sections.map((section) => (); };))}{section.header}{section.body}
명령과 함께 npm을 사용하여 jQuery를 설치하십시오 :
npm jQuery 설치 --save npm i ---save-dev @type/jquery
jquery를 JSX 파일로 가져 가야합니다. Reactjs
아코디언의 jQuery 코드를 REACTJ로 변환하려면 상태 관리를 사용하여 신체 섹션의 가시성을 처리 할 수 있습니다. 예는 다음과 같습니다.import React, {usestate} 'react'; const 아코디언 = () => { const [activesection, setActivesection] = usestate (null); const handleheadClick = (e) => { const 섹션 = e.target.parentElement; if (section === activessection) { setActivesection (null); } 또 다른 { setActivesection (섹션); } }; 반품 (
[&&)
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3