是否可以在 Typescript 记录中找到项目数?
例如类似的东西
const testRecord: Record<string, string> = {
'one': 'value1',
'two': 'value2'
};
var length = testRecord.length;
// looking for length to be 2 but is undefined as there is no length property
Run Code Online (Sandbox Code Playgroud)
供参考:https : //www.typescriptlang.org/docs/handbook/utility-types.html#recordkt