gpt4 book ai didi

node.js - 如何删除node.js中短信中的空格?

转载 作者:太空宇宙 更新时间:2023-11-03 23:55:28 24 4
gpt4 key购买 nike

我们正在使用node.js 通过短信发送预订确认消息。如果我们使用中断标签,它会显示 <br />与消息一起使用,因此我们使用\n 在特定行之后给出中断。但我们在短信中出现了空白。我们怎样才能删除空白有人可以帮助我吗?

otpMessages(otp, doctor_fullname, passwd, mobile_number) {
return `
x has invited you to join Platform.
Please click on the following link to download and register. \n
Your OTP is ${otp}. \n
Download App: (app link) \n

Thanks,
`;
},

最佳答案

您可以从字符串模板中删除所有额外的缩进,但代码看起来很难看。

所以我建议通过连接字符串来实现。

示例:

otpMessages(otp, doctor_fullname, passwd, mobile_number) {
return [
'x has invited you to join Platform. Please click on the following link to download and register.',
`Your OTP is ${otp}.`,
'Download App: (link)',
'Thanks,'
].join('\n\n')
},

结果:

x has invited you to join Platform. Please click on the following link to download and register.

Your OTP is <otp>.

Download App: (link)

Thanks,

关于node.js - 如何删除node.js中短信中的空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57413272/

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