<li th:each="grade : ${grades}" th:v-bind:class="|{current: gradeId==${grade.id}}|"> <a th:title="${grade.name}" href="javascript:void(0)" th:id="${grade.id}" th:text="${grade.name}" th:@click="|getCourses(${grade.id},subjectId,1)|" >二年級</a></li>
th:@click="|getCourses(${grade.id},subjectId,1)|"
@click為VUE里綁定的點擊事件,此時事件存在於thymeleaf的循環th:each下的元素,getCourses() 為vue里的方法屬於js,但是需要取到模板里產生的值<年級id>
此時可以用th:v-on:"| |" 或者th:@click="| | " 簡單來說就是將前端的方法當作字符串拼接起來,前面加th:就能解析${grade.id} 的值
th:v-bind:class="|{current: gradeId==${grade.id}}|"
同理,綁定class用於樣式也能如此