<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>try</title>
<!-- 引用 css-->
<link rel="stylesheet" href="./lib/css/bootstrap-3.3.4.css">
<link rel="stylesheet" href="./lib/css/element-ui.css">
<link rel="stylesheet" href="./lib/css/bootstrap-table.min.css">
<!-- 引用js=================== -->
<script src="./lib/js/jquery-3.5.1.min.js"></script>
<script src="./lib/js/vue-2.6.12.js"></script>
<script src="./lib/js/bootstrap-3.3.7.min.js"></script>
<script src="./lib/js/bootstrap-table.min.js"></script>
<script src="./lib/js/element-ui.js"></script>
</head>
<body>
<div id='td' style="padding-left: 15px;padding-right:15px;">
<div>
<h2>总表</h2>
<table id="tableDetails1" class="table table-hover table-bordered" style="color: #000000">
</table>
</div>
</div>
<script>
var vm = new Vue({
el: "#td",
data: {
},
mounted: function () {
var that = this;
that.$nextTick(function () {
that.tableDetails1();
$("#tableDetails1").on("click-cell.bs.table", function ($element, field, row, value) { //点击触发事件
alert("field:" + field);
alert("row:" + row);
alert("value:" + JSON.stringify(value));
alert("当前点击的是:工号为" + value.jobNum + "," + field + "=" + row + "的记录")
});
})
},
methods: {
tableDetails1() {
$('#tableDetails1').bootstrapTable('destroy').bootstrapTable({
singleSelect: true,
clickToSelect: true,
showColumns: true,
cache: false,
pagination: true,
pageNumber: 1,
pageSize: 10,
pageList: [10, 25, 50, 100],
columns: [{ // table
field: 'jobNum',
title: '工号',
width: 80,
visible: true,
align: 'center',
}, {
field: 'accountUnit',
title: '核算单位',
width: 80,
visible: true,
align: 'center',
}, {
field: 'name',
title: '姓名',
width: 80,
visible: true,
align: 'center',
},],
data: [{
jobNum: 1,
accountUnit: 803,
name: "Bella",
}, {
jobNum: 2,
accountUnit: 804,
name: "jean",
}, {
jobNum: 3,
accountUnit: 805,
name: "ter",
}],
});
$("#tableDetails1").on("click-cell.bs.table", function ($element, field, row, value) {
alert("field:" + field);
alert("row:" + row);
alert("value:" + value.jobNum);
alert("当前点击的是:工号为" + value.jobNum + "," + field + "=" + row + "的记录")
});
},
},
})
</script>
</body>
</html>