javascript - 如何在 TypeScript 中执行字符串插值?

标签 javascript typescript string-interpolation

C#使用字符串插值

int value = 100;
Console.WriteLine($"The size is {value}.");

输出:

The size is 100.

如何在 TypeScript 中做同样的事情?

最佳答案

在 JavaScript 中你可以使用 template literals :

Template literals are literals delimited with backticks (`)

let value = 100;
console.log(`The size is ${ value }`);

关于javascript - 如何在 TypeScript 中执行字符串插值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45399951/

相关文章:

typescript - 您可以将类型别名传递给 TypeScript 中的接口(interface)吗?

typescript - 为什么 TypeScript 数组是协变的?

json - jq --arg 变量在 select() 中的引用字符串中使用

powershell - POST请求变量powershell

ios - 验证字符串是否为货币格式

javascript - 运行按钮的功能

javascript - 使用 jQuery 递归更改元素类型,为什么它部分起作用?

javascript - mongoose 查找多个条件的记录并检查请求参数是否不为空

javascript - 尝试包含对数和三 Angular 函数

javascript - typescript 返回类型为 'void' 的参数不能分配给类型为“TimerHandler?”的参数?