recipes: {
"Cupcakes": {name: "Cupcakes", available: true, ingredients: "", directions: ""},
"Cookies": {name: "Cookies", available: false, ingredients: "", directions: ""},
"Sushi": {name: "Sushi", available: true, ingredients: "", directions: ""},
"Apple_Pie": {name: "Apple_Pie", available: true, ingredients: "", directions: ""}
},
如何从关键的“寿司”中获取成分?
答案 0 :(得分:2)
你可以像这样访问它:
var ingredients = recipes.Sushi.ingredients;
答案 1 :(得分:0)
应该是
如果你的食谱是指定的
var myrecipes = {recipes: {
"Cupcakes": {name: "Cupcakes", available: true, ingredients: "", directions: ""},
"Cookies": {name: "Cookies", available: false, ingredients: "", directions: ""},
"Sushi": {name: "Sushi", available: true, ingredients: "", directions: ""},
"Apple_Pie": {name: "Apple_Pie", available: true, ingredients: "", directions: ""}}
},
console.log(myrecipes.recipes.Shushi);