我有一张地图,用于设置项目的引用。在这种情况下,它是video
。
const ref = this[`video-${index}-ref`];
如何正确输入此内容?索引的数量可以不同。
答案 0 :(得分:1)
如果所有类型
this[`video-${index}-ref`];
相似并且知道(例如,它们都是VideoRefType
),可以进行类型转换,如下所示:
const ref = ((this[`video-${index}-ref`]: any): VideoRefType);