1
<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript">
</script>
<div id="login_button" onclick="VK.Auth.login(getit);"></div>
<script language="javascript">
VK.init({
    apiId: 2903251
});
function getit(response) {
    if (response.session) {
        var id = response.session.mid;
    }
    VK.Api.call('users.get', {uids: id, fields: 'sex,photo_big'}, function(r) {
        if(r.response) {
            alert(r.response.sex);
            console.log(r.response);
        }
    });
}
VK.UI.button('login_button');
</script>

为什么alert(r.response.sex)显示未定义,但控制台日志一切正常?

4

1 回答 1

1

解决了。解决方案:r.response[0].sex

于 2012-05-24T09:11:42.283 回答