Bre*_*dan 6 newline response line-breaks node.js express
我正在尝试使用 Express 发送带有换行符的字符串。
const express = require('express');
const app = express();
persons = [//...];
app.get('/info', (req,res) => {
res.send(`Phonebook has info for ${persons.length} people.
${Date()}`);
});
Run Code Online (Sandbox Code Playgroud)
我在网上读到,从 ES6 开始,反引号可用于构造多行,但它似乎不起作用。
我想要的输出是:
Phonebook has info for 4 people.
Thu Oct 10 2019 18:54:01 GMT-0700 (Pacific Daylight Time)
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下方法:
app.get('/info', (req,res) => {
res.send(`Phonebook has info for ${persons.length} people.\n${Date()}`);
});
Run Code Online (Sandbox Code Playgroud)
我在网上读到你也可以只使用 '\n' 但这也不起作用。
我究竟做错了什么?我一直在遵循我在网上找到的建议,但我无法显示新的一行。
| 归档时间: |
|
| 查看次数: |
5232 次 |
| 最近记录: |