首页 > 编程语言 > 详细

spring boot 使用 Thymeleaf +layui 使用到的功能实例

时间:2020-05-11 18:21:46      阅读:64      评论:0      收藏:0      [点我收藏+]

1.input 标签回显

使用th:value标签进行回先,后端使用 ModelMap 将查询到的对象或list 传到前台

前台使用 <input type = "text" th:value = "user.userName"  id = "userName" name = "userName" >进行回显

2.select 标签回显

使用 th:field 标签进行回显,

前台使用  

<select th:field="user.type" name = "type" id = "type" >
    <option th:case="‘1‘" th:selected = "selected" value="1" > 1</option>
    <option th:case="‘2‘" th:selected = "selected" value="2" > 2</option>
</select>

3.textarea 标签回显

使用th:text标签进行回显

前台使用

<textarea th:text="${user.content}" class="layui-textarea" style="width: 700px;height: 100px;" id="riskContent" name="riskContent" disabled></textarea>

4. 使用th:each 进行循环list 展示表格

<table class="layui-table" style="width: 80%; /*margin: 0 auto;*/">
  <thead>
     <tr>
        <th>文件名称</th>
         <th>文件类型</th>
         <th>上传时间</th>
         <th>操作</th>
      </tr>
   </thead>

      <tr th:each="info,findCsRiskFile : ${findCsRiskFile}">
         <td th:text="${info.fileName}"></td>
         <td th:text="${info.fileType}"></td>
         <td th:text="${#dates.format(info.mmCreatetime, ‘yyyy-MM-dd HH:mm:ss‘)}"></td>
         <td><a href="javascript:void(0)" th:data="${info.mmId}"  th:onclick = "‘javascript:deleteFile(\‘‘ + ${info.mmId} + ‘\‘)‘">删除</a>
        <a th:href="${info.mmRelative}+${info.pdfName}" target="_blank">预览</a>
             <a th:href="@{‘/csRisk/downloadFile?mmId=‘+${info.mmId}}">下载</a>
         </td>
      </tr>
</table>

5. 使用 th:onclick 跳转触发事件

<a href="javascript:void(0)" th:data="${info.fileId}"  th:onclick = "‘javascript:deleteFile(\‘‘ + ${info.fileId} + ‘\‘)‘">删除</a>

6. layUi 根据table数据判断按钮显示情况

{fixed: ‘right‘, title:‘操作‘, toolbar: ‘#barDemo‘, width:150,align:"center"}
<script type="text/html" id="barDemo">

    {{#  if(d.type== 0){ }}
        <a herf="javascript:;" lay-event="release" >发布</a>
        <a herf="javascript:;" lay-event="detail" >查看详情</a>
    {{# }if(d.type == 1){ }}
        <a herf="javascript:;" lay-event="detail" >查看详情</a>
    {{# } }}
</script>

7. layUi 中对table 中数据 判断 (0 否 1 是 )

{field: ‘isRelease‘, title: ‘是否发布‘, minWidth:100, align:"center"}}],

done: function (res, curr, count) {

  $("[data-field=‘earlywarnIsrelease‘]").children().each(function(){
     if($(this).text()==‘1‘){
        $(this).text("是")
      }else if($(this).text()==‘0‘){
         $(this).text("否")
      }
   });
}

未完待续.....

 

    

spring boot 使用 Thymeleaf +layui 使用到的功能实例

原文:https://www.cnblogs.com/yypr/p/12870302.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!