react.js : javascript in angle brackets not working

后端 未结 2 416
栀梦
栀梦 2021-01-28 09:24

For some reason when I try and enter JavaScript into the angle part of the HTML portion it does not work. I\'m using Thymeleaf.

Here\'s the HTML portion:



        
相关标签:
2条回答
  • 2021-01-28 09:53

    I was getting the error because Thyemleaf thought that I was typing HTML: I just added this:

      /*<![CDATA[*/
      ...
      /*]]>*/
    
    0 讨论(0)
  • 2021-01-28 10:08

    Try this:

    <button className="btn btn-info" onClick={() => this.displayInfo()}>Click for info about {firstName[i]}</button>
    

    you should pass an arrow function in your onClick event

    0 讨论(0)
提交回复
热议问题