我想从Interface映射2个值:
export interface CurrenciesList {
currency: string;
country: string;
}我想把结果描绘成这样:
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: i.currency }));但我想把这样的结果结合起来:
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: i.currency - i.country }));但我得到了结果。我想把这一结果列入清单:
USD - United States正确的映射方法是什么:name: i.currency - i.country
发布于 2019-05-02 09:05:10
你可以试试这个。如果您不熟悉这个语法,我将使用ES6的模板文字。在某些情况下,它可以使字符串连接更干净。
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: `${i.currency} - ${i.country}` }));https://stackoverflow.com/questions/55948988
复制相似问题