gpt4 book ai didi

javascript - 引用错误 : document is not defined in Nodejs

转载 作者:行者123 更新时间:2023-11-30 19:18:58 33 4
gpt4 key购买 nike

<分区>

我想在 id='name' 的 html p 标签中显示来自 nodejs 的变量'name'。何时加载 html 页面?

view.html

<html>
<head>
<title>TRY</title>
</head>
<body>
<p id="name"></p>
</body>
<script type="text/javascript" src="try.js"></script>
</html>

try.js

var http = require ('http');
var express = require('express');
var app = express();
var server = http.createServer(app);
var name = "Ronish";
app.use(express.static('public'));
document.getElementById('name').innerHTML=name;
server.listen('3030');
console.log('Listening on port 3030');

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com