【问题标题】:What would an interface to describe an array of ASP.NET Modelstate look like in Typescript?在 Typescript 中描述 ASP.NET Modelstate 数组的接口是什么样的?
【发布时间】:2015-09-23 18:34:42
【问题描述】:

我的模型状态看起来像这样:

 var ModelState = {
    "model.StartDate": [ "The Start Date field is required." ],
    "model.EndDate": [ "The End Date field is required." ]
 }

然后我使用这个脚本将它放入一个数组中:

var errors = [];
Object.keys(ModelState).forEach(function (key) {
   errors.push.apply(errors, ModelState[key]);
});

谁能帮我告诉我 Typescript 对错误的定义是什么。我意识到这将是一个数组,但我怎样才能表示内容?

【问题讨论】:

  • 你能再描述一下你的问题吗

标签: javascript typescript


【解决方案1】:

您可以使用 custom JS errors 定义错误,或者如果您想使用 C# 中的某些类型,您可以使用 this tool 将 C# 类型转换为 TypeScript 类型。

【讨论】:

    猜你喜欢
    • 2016-03-24
    • 2017-08-08
    • 2020-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-19
    • 2015-02-18
    • 2019-04-06
    相关资源
    最近更新 更多