String.Format 在 TypeScript 中不起作用 [英] String.Format not work in TypeScript
本文介绍了String.Format 在 TypeScript 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String.Format
在 TypeScript
中不起作用.
错误:
类型的值上不存在属性格式"'{ 原型:字符串;fromCharCode(...codes: number[]): string;(值?:任何):字符串;新(值?:任何):字符串;}'.
<小时>
attributes["Title"] = String.format(Settings.labelKeyValuePhraseCollection["[WAIT DAYS]"],originalAttributes.Days);
解决方案
你可以很容易地声明:
interface StringConstructor {格式: (formatString: string, ...替换: any[]) =>细绳;}String.format('','');
这是假设 String.format 在别处定义.例如在 Microsoft Ajax 工具包中:http://www.asp.net/ajaxlibrary/Reference.String-format-Function.ashx
String.Format
does not work in TypeScript
.
Error:
The property 'format' does not exist on value of type '{ prototype: String; fromCharCode(...codes: number[]): string; (value?: any): string; new(value?: any): String; }'.
attributes["Title"] = String.format(
Settings.labelKeyValuePhraseCollection["[WAIT DAYS]"],
originalAttributes.Days
);
解决方案
You can declare it yourself quite easily:
interface StringConstructor {
format: (formatString: string, ...replacement: any[]) => string;
}
String.format('','');
This is assuming that String.format is defined elsewhere. e.g. in Microsoft Ajax Toolkit : http://www.asp.net/ajaxlibrary/Reference.String-format-Function.ashx
这篇关于String.Format 在 TypeScript 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文