我正在开发一个node.js项目,我想在其中实现创建模板。基本上,我有一个html骨架。
<html>
<head>
--- script file---
</head>
<body>
here i want to include html table on click the button
</body>
</html>
当我点击按钮时,我想要包含一个我已经存在的html字符串 编码。我试过跟随html字符串。
html+=
'<div style="margin-top: 2%">' +
'<table border-collapse: collapse; border="1" width="100%" style="background-color:#b3b3b3 " font-family: Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif cellspacing="0" cellpadding="7">' +
'<tr>' +
'<th align="center" style="font-size: 12px">DEMO CTS' +
'</th>' +
'</tr>' +
'</table>' +
'</div>' +
'<div style="margin-top:2%">' +
'<table border-collapse: collapse; border="1" style="width: 100%;font-family: Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif" cellspacing="0" cellpadding="5">' +
'<tr style="background-color: #b3b3b3;text-align: center;">' +
'<th colspan="4" style="font-size: 12px"><b>BACKGROUND CHECK - SUMMARY</b></th>' +
'</tr>' +
'<tr>' +
'<th style="background-color: #b3b3b3;width: 25%;font-size: 12px" align="left"><b>CMC APPLICANT ID</b></th>' +
'<td style="font-size: 12px" width="28%">'+data.applicantId+'</td>' +
'<th style="background-color: #b3b3b3;width: 25%;font-size: 12px" align="left"><b>VENDOR RF-ID</b></th>' +
'<td style="font-size: 12px">'+data.vendorId+'</td>' +
'</tr>' +
'<tr>' +
'<th style="background-color: #b3b3b3;font-size: 12px" align="left"><b>RECRUITMENT BRANCH</b></th>' +
'<td style="font-size: 12px">'+data.branch+'</td>' +
'<th style="background-color: #b3b3b3;font-size: 12px; width: 15%" align="left"><b>NSR IT_PIN</b></th>' +
'<td style="font-size: 12px">'+data.nsrPin+'</td>' +
'</tr>' +
'<tr>' +
'<th style="background-color: #b3b3b3;font-size: 12px;width: 15%" align="left"><b>NAME OF THE CANDIDATE</b></th>' +
'<td colspan="3" style="font-size: 12px">'+data.name+'</td>' +
'</tr>' +
'<tr>' +
'<th style="background-color: #b3b3b3;font-size: 12px" align="left"><b>DATE OF BIRTH</b></th>' +
'<td style="font-size: 12px">'+data.dob+'</td>' +
'<th style="background-color: #b3b3b3; font-size: 12px;width: 25%" align="left">FINAL BGC STATUS (RED,GREEN)</th>' +
'<td style="background-color:orange">Amber</td>' +
'</tr>' +
'<tr>' +
'<th style="background-color: #b3b3b3;font-size: 12px; width: 10%;" align="left"><b>CATEGORY (CAMPUS/DT/EP/EP FROM CAMPUS)</b></th>' +
'<td style="font-size: 12px">'+data.category+'</td>' +
'<td style="font-size: 12px" colspan="2"></td></tr></table>';
答案 0 :(得分:-1)
Node.js有多个模板模块,例如EJS或Jade。我建议使用这些,而不是自己创建。
见