简体   繁体   English

从 myStrings 命名的接口属性名称

[英]Interface Property name named from myStrings

I typed up a bunch of strings for a project:我为一个项目输入了一堆字符串:

declare interface IMyWebPartStrings {
  PropertyDamage: string;
  EventWorkRelated: string;
  EmployeeWearingProperPPE: string;
  YourSupervisor: string;
  Region: string;
  Branch: string;
  PositionTitle: string;
  LocationOfEvent: string;
  DateOfIncident: string;
  InvolvedPeople: string;
  EventDetails: string;
  CorrectiveActions: string;
  CorrectiveActionsDetails: string;
  ...
}

I am creating an interface and it will have all the same names.我正在创建一个interface ,它将具有所有相同的名称。

When I create the interface , is there a way I can name the properties from the myStrings list?当我创建interface ,有没有办法从 myStrings 列表中命名属性?

No, that is not possible.不,那是不可能的。

Quick explanation: Interfaces are defined before compilation of the code, but the contents of the myStrings list is only known after, when the code is run (even when you hard-code the value of myStrings, this won't get interpreted until the code is run).快速解释:接口是在代码编译之前定义的,但是 myStrings 列表的内容只有在代码运行之后才知道(即使你对 myStrings 的值进行了硬编码,这也不会被解释,直到代码正在运行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM