每当我尝试运行服务器来可视化基本HTML文件中的不一致数据时,都会得到“未定义文档”的信息。
这是discord.js代码:
client.on('guildMemberUpdate', (oldMember, newMember) => {
var tr = document.createElement('tr');
var tdServer = document.createElement('td');
var tdOldName = document.createElement('td');
var tdNewName = document.createElement('td');
tdServer.innerText = oldMember.guild.name;
tdOldName.innerHTML = oldMember.nickname;
tdNewName.innerHTML = newMember.nickname;
dcTable.append(tr);
tr.append(tdServer, tdOldName, tdNewName);
});
和html文件:
<body>
<h1 style="text-align: center;">Logs</h1>
<table id="dcTable" style="text-align: center; margin-left: 37%">
<tr>
<th>Guild</th>
<th>Old nick</th>
<th>New nick</th>
<th>Date</th>
</tr>
</table>
<script src="index.js"></script>
</body>
错误提示:
var tr = document.createElement('tr');
^
ReferenceError: document is not defined