如何从此对象访问值:
{
"user_voted_1": "1",
"user_voted_2": "1",
"user_voted_3": "1"
}
答案 0 :(得分:0)
点符号(object.property
):
console.log(data.user_voted_1);
答案 1 :(得分:0)
假设您的代码是
var data = {
"user_voted_1": "1",
"user_voted_2": "1",
"user_voted_3": "1"
};
您可以使用以下某种模式访问属性:
var x = data.user_voted_1; // x = "1"
var y = data["user_voted_2"]; // y = "1"
另一方面,如果您遇到此问题,我建议您继续阅读一些有关Javascript的教程;否则你可能遇到一些真正的问题...