When the parameter of the JS function is an object, the object cannot be passed directly when calling, but it can be used after the object user JSON conversion, as follows
Pay special attention to this return "<button class='btn btn-primary btn-sm" οnclick='toEdit(" + JSON.stringify(row) + ")'>Edit</button>";
Here's double and single quotes are easy to confuse, the easiest way is to directly copy this line of code and then modify its contents
formatter: function(value, row, index) {
return "<button class='btn btn-primary btn-sm'' onclick='toEdit(" + JSON.stringify(row) + ")'>编辑</button>";
}
function toAdd(){
$("#myModalLabel").text("新增");
$("#myModal").find(".form-control").val("");
$('#myModal').modal()
}