我有一个枚举:
const ingredients = {
BREAD_BOTTOM: 'BreadBottom',
BREAD_TOP: 'BreadTop',
MEAT: 'Meat',
BACON: 'Bacon',
CHEESE: 'Cheese',
SALAD: 'Salad'
};
现在我想使用这个枚举创建一个成分列表,比如:
listOfIngredients: {
ingredients.BREAD_TOP: 1,
ingredients.BACON: 1,
ingredients.CHEESE: 2,
ingredients.MEAT: 2,
ingredients.BREAD_BOTTOM: 1,
}
我尝试了一些变化,例如,${ingredients.BREAD_TOP}
但我不能让成分列表作为 Enum 值的关键