0
可能重复:
JavaScript equivalent to printf/string.format我们在JavaScript中有类似C#String.Format(...)的东西吗?
我们有没有像C#的String.Format(...)在JavaScript?我喜欢能够说String.Format('text text {0},text text {1}',value1,value2);
并且理想地作为一个扩展方法:
'的文本的文本{0},文本文本{1}' 格式(值1,值2);
感谢,
怎么可能有格式的方法字符串实例的扩展方法是什么?例如使用“text {0} text {1}”来访问它。format(value1,value2);好处是代码少。 –
@William:https://gist.github.com/1096824 – pimvdb
如何以与我在C#中使用扩展方法相同的方式使用上述代码? –