function callBack(data1, predicted_label){
const resultParagraph = document.getElementById("resultParagraph");
resultParagraph.textContent = `Sentiment: ${predicted_label}`;
const historyList = document.getElementById("historyList");
const listItem = document.createElement('li');
listItem.textContent = `Text: ${data1} Sentiment: ${predicted_label}`;
historyList.prepend(listItem); }
在此代码中,我想在
Text: ${data1} Sentiment: ${predicted_label}
之间添加新行。
我尝试添加
,尝试添加
标签,但似乎没有效果
HTML 渲染不考虑换行符 - 您需要使用 innerHTML 而不是 textContent 并在想要换行的位置添加
<br>
标记