您的代码应该是:
function testPrint() {
let Name = '<td class="px-6 py-4 whitespace-no-wrap">Kevin</td>';
let bmi = '<td>20</td>';
let message = '<td class="px-8 py-4 whitespace-wrap">';
message += 'from the data report that we got it is determined that you are overweight';
message += '</td>';
let btnAction = '<td class="flex px-3 py-4 whitespace-no-wrap">'
btnAction += '<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mr-2">Edit</button>'
btnAction += '<button class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">Delete</button>'
btnAction += '</td>'
document.getElementById(
"dataTable"
).innerHTML += `<tr>${Name}${bmi}${message}${btnAction}</tr>`;
}
因为你的代码没有定义变量“genre”,所以我把它从innerHTML中删除了。