一、使用详解
1.没有参数
实例:
<button th:onclick="getInfo()">按钮1</button>
html编译结果:
<button onclick="getInfo()">按钮1</button>
2.一个参数
实例:
info.id = "9999";
<button th:onclick="getInfo([[${info.id}]])">按钮2</button>
html编译结果:
<button onclick="getInfo("9999")">按钮2</button>
3.多个参数
实例:
info.id = "9999";
info.age= "30";
<button th:onclick="getInfo([[${info.id}]], [[${info.age}]])">按钮3</button>
html编译结果:
<button th:onclick="getInfo("9999", "30")">按钮3</button>
4.多个参数并且包含表达式
实例:
info.id = "9999";
info.sex= "1";
<button th:onclick="getInfo([[${info.id}]], [[${info.sex==1?'男':'女'}]])">按钮4</button>
html编译结果:
<button th:onclick="getInfo("9999", "男")">按钮4</button>