-
글쓴이글
-
2023년 6월 17일 22:52 #87371
가보자고참가자이미 만들어져있는 HTML 템플릿을 React 프로젝트로 변경하였습니다 다른거는 다 괜찮은데 javascript 파일이 적용되지 않습니다 기존 html 템플릿에 있던 script 를 React 프로젝트 내 index.html body 태그에 옮겨 작성했습니다 어떤 .js 파일은 적용되는데 어떤 파일은 적용되지 않았습니다 렌더링 완료 시점이 차이가 나서 그런거 같은데 어떻게 해결해야할지 모르겠습니다 아래는 프로젝트 구조입니다
아래는 리액트 프로젝트 내 index.html 파일 입니다
<div>
<div><!DOCTYPE html></div>
<div><html lang="en"></div>
<div> <head></div>
<div> <meta charset="utf-8" /></div>
<div> <meta name="viewport"</div>
<div> content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /></div>
<div> </div>
<div> <title>Container - Layouts | Sneat - Bootstrap 5 HTML Admin Template - Pro</title></div>
<div> </div>
<div> <meta name="description" content="" /></div>
<div> </div>
<div> <!-- Favicon --></div>
<div> <link rel="icon" type="image/x-icon" href="%PUBLIC_URL%/assets/img/favicon/favicon.ico" /></div>
<div> </div>
<div> <!-- Fonts --></div>
<div> <link rel="preconnect" href="https://fonts.googleapis.com" /></div>
<div> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /></div>
<div> <link</div>
<div> href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"</div>
<div> rel="stylesheet" /></div>
<div> </div>
<div> <!-- Icons. Uncomment required icon fonts --></div>
<div> <link rel="stylesheet" href="%PUBLIC_URL%/assets/vendor/fonts/boxicons.css" /></div>
<div> </div>
<div> <!-- Core CSS --></div>
<div> <link rel="stylesheet" href="%PUBLIC_URL%/assets/vendor/css/core.css" class="template-customizer-core-css" /></div>
<div> <link rel="stylesheet" href="%PUBLIC_URL%/assets/vendor/css/theme-default.css" class="template-customizer-theme-css" /></div>
<div> <link rel="stylesheet" href="%PUBLIC_URL%/assets/css/demo.css" /></div>
<div> </div>
<div> <!-- Vendors CSS --></div>
<div> <link rel="stylesheet" href="%PUBLIC_URL%/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" /></div>
<div> </div>
<div> <!-- Page CSS --></div>
<div> </div>
<div> <!-- Helpers --></div>
<div> <script src="%PUBLIC_URL%/assets/vendor/js/helpers.js"></script></div>
<div> </div>
<div> <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section --></div>
<div> <!--? Config: Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file. --></div>
<div> <script src="%PUBLIC_URL%/assets/js/config.js"></script></div>
<div> </head></div>
<div> <body></div>
<div> <noscript>You need to enable JavaScript to run this app.</noscript></div>
<div> <div id="root"></div></div>
<div> <!--</div>
<div> This HTML file is a template.</div>
<div> If you open it directly in the browser, you will see an empty page.</div>
<div> You can add webfonts, meta tags, or analytics to this file.</div>
<div> The build step will place the bundled scripts into the <body> tag.</div>
<div> To begin the development, run `npm start` or `yarn start`.</div>
<div> To create a production bundle, use `npm run build` or `yarn build`.</div>
<div> --></div>
<div> <!-- Core JS --></div>
<div> <!-- build:js assets/vendor/js/core.js --></div>
<div> <script src="%PUBLIC_URL%/assets/vendor/libs/jquery/jquery.js"></script></div>
<div> <script src="%PUBLIC_URL%/assets/vendor/libs/popper/popper.js"></script></div>
<div> <script src="%PUBLIC_URL%/assets/vendor/js/bootstrap.js"></script></div>
<div> <script src="%PUBLIC_URL%/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script></div>
<div> </div>
<div> <script async defer src="%PUBLIC_URL%/assets/vendor/js/menu.js"></script></div>
<div> <!-- endbuild --></div>
<div> </div>
<div> <!-- Vendors JS --></div>
<div> </div>
<div> <!-- Main JS --></div>
<div> <script src="%PUBLIC_URL%/assets/js/main.js"></script></div>
<div> </div>
<div> <!-- Page JS --></div>
<div> </div>
<div> <!-- Place this tag in your head or just before your close body tag. --></div>
<div> <script async defer src="https://buttons.github.io/buttons.js"></script></div>
<div> </body></div>
<div></html></div>
</div>2023년 6월 18일 11:30 #87416
가보자고참가자모든 script 태그를 index.html 파일 내 head 태그안에 뒀는데 이전에 말했던거처럼 어떤거는 작동하고 어떤거는 작동안합니다 참고로 console에 찍히는것도 없습니다
2023년 6월 18일 11:58 #87421
가보자고참가자혹시몰라 깃허브에 React 코드 업로드 했습니다 참고부탁드립니다 https://github.com/weatherbetter/React-temp
HTML 템플릿은 아래 파일 사용했습니다 https://themewagon.com/themes/free-responsive-bootstrap-5-html5-admin-template-sneat/ 아래 이미지 캡처처럼 프로필 부분은 클릭하면 작동하는데 옆에 사이드바가 작동하지 않습니다
2023년 6월 18일 21:26 #87464
가보자고참가자Helmet 을 설치해 사용하는 자바스크립트 파일을 직접 넣어주면 작동은 합니다 (공유드린 깃허브 내 src/pages/Home.js 파일 참고 부탁드립니다!) 하지만 이렇게 되면 모든 파일에 같은 방식으로 적용해야합니다 index.html 에 적용하고 싶습니다 어떻게 하면 좋을까요...
2023년 6월 19일 10:00 #87507
codingapple키 마스터자바스크립트 파일안의 내용들을 페이지 로드 완료시 실행하라고 코드를 추가하거나 아니면 useEffect에 복사붙여넣기 해서 써야할듯요
-
글쓴이글
- 답변은 로그인 후 가능합니다.