Kir*_*ath 1 visual-studio node.js express node-modules reactjs
我已经在app.js中使用此代码制作了在控制台中显示端口的信息,但在下面无法正常工作只是整个代码的一部分
const port = 8080;
app.listen(port, () => {
console.log("hi its listening: ${port}!");
});
Run Code Online (Sandbox Code Playgroud)
这是控制台的输出
hi its listening: ${port}!
const express=require('express');
const app=express();
const morgan=require('morgan');
const postRoutes=require("./routes/post");
app.use(morgan("dev"));
app.use('/',postRoutes);
const port = 8080;//process.env.PORT || 8080;
app.listen(port, () => {
console.log("hi its listening: ${port}!");
});
Run Code Online (Sandbox Code Playgroud)
它应该显示:
hi its listening: 8080
Run Code Online (Sandbox Code Playgroud)
您可以使用模板字符串(带有反引号-``)或字符串串联:
// Template Strings example ...
console.log(`hi its listening: ${port}!`);
// String concatenation example ...
console.log('hi its listening: ' + port + '!');
Run Code Online (Sandbox Code Playgroud)