HTML statique:
<table lay-filter = "goods-table" id = "Goods-table" class = "table-list my-table-list" cellspacing = "0" cellpadding = "0" style = "display: none;">
< thead>
<tr>
<th lay-data = "{type: 'checkbox'}"> </th>
<th lay-data = "{field: 'a'}"> ID111 </th>
<th lay- data = "{field: 'b'}"> deals on 图 </th>
<th lay-data = "{field: 'c'}"> describe on 标题 </th>
<th lay-data = "{champ: 'd'} "> deals on 价格 </th>
<th lay-data =" {champ: 'e'} "> Marque de produit </th>
<th lay-data =" {field: 'g'} "> Série de produits </th>
<th lay-data =" {field: 'h'} "> Fournisseur </th>
</tr>
</thead>
<tbody>
<tr>
<td> </td>
<td> ID111111 </td>
<td> <img src = "http: // localhost: 9020 / images / addImg.png" class = " shopImg "/> </td>
<td> ″ ″ 1 </td>
<td> ¥ 100 </td>
<td> ″ ″ ″ 1 </td>
<td> 产 1 </td>
<td>所属 供应 一 1 </td>
</tr>
<tr>
<td> </td>
<td> ID2222 </td>
<td> <img src = "http: // localhost: 9020 / images / addImg.png" class = "shopImg" /> </td>
<td> Paramètres de fabrication 标题 2 </td>
<td> 200 ¥ </ td>
<td> 商 2 </td>
<td> 2 </td>
<td> 所属 供应 商 2 </td>
</tr>
</tbody>
</table>
<div id = " page "data-count =" 10 "data-limit =" 10 "data-page =" 1 "> </div>
js partie:
Obtenez toutes les données sélectionnées:
var selectData = layui.table.checkStatus ('table des marchandises'). data; // table des marchandises 是 table 的 id
console.log (selectData);
Écoutez chaque sélection:
layui.use (['table'], function () { var table = layui.table; table.on ('checkbox (Goods-table)', function (obj) { console.log (obj.checked); // Si l'état actuel est sélectionné console.log (obj.data); // Données pertinentes de la ligne sélectionnée console.log (obj.type); // Si le déclencheur est select all, c'est: all, si le déclencheur est une sélection unique, Ensuite: one console.log (table.checkStatus ('Goods-table'). Data); // Récupère les données de la ligne sélectionnée dans le tableau })