単純なオブジェクトのプロパティにアクセスできません。
これは私が実行したときに得られるものですalert(JSON.stringify(user)):
{"username": "david", "biography": "Hello world."}
しかし、これは私が実行したときに得られるものですalert(user.username):
undefined
私もuser["username"]同じ結果で試しました。これは、ハンドルバーを使用するバックボーン アプリケーションのコンテキストにあります。バックボーン部分は次のとおりです。
var User = Backbone.Model.extend({
  urlRoot: 'http://api.example.com/user',
});
var Router = Backbone.Router.extend({
  routes: {
    ":username": "profile"
  },
  profile: function (username) {
    var user = new User({id: username});
    user.fetch({
      beforeSend: authenticate,
      success: function() {
        var profile = new Profile({user: user});
        profile.render();
      }
    });
  }
});
var Profile = Backbone.View.extend({
  render: function() {
    var source = $("#profile").html();
    var template = Handlebars.compile(source);
    user = this.options.user;
    var html = template(user);
    $("#content section").html(html);
  }
});
そのような問題の原因は何ですか?