js 파일에서 thymeleaf 변수 사용하는 방법 #97
newuserYejin
started this conversation in
shared
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
✏️ 제목
제목을 입력해주세요.
외부 js 파일에서 thymeleaf 변수 사용하는 방법
✅ 공유 내용
외부의 js 파일에서 thymeleaf 변수를 사용할 수 없다.
( ${number} 와 같은 형태를 js파일에서는 사용 불가 )
javascript <script type="text/javascript" th:src="@{/js/header/header.js}"></script>와 같은 형식으로 외부의 js를 적용 할 수 있지만 변수를 바로 가져가 사용하는건 불가능하다.( js의 내용이 길어질 경우를 대비하여 따로 js 파일을 만드는 것이 깔끔해보인다. )
와 같이 외부 js파일에서 사용할 변수를 <script></script> 태그에서 먼저 작성해주면 이어지는 외부 js파일에서 사용 가능하다.
🔗 알게된 사실 및 유용한 참고 관련 링크 (Links)
[참고한 링크]
https://purplecloudtosunny.tistory.com/36
📷 참고 사진
여기에 참고 사진을 추가할 수 있습니다.
Beta Was this translation helpful? Give feedback.
All reactions