如何Return解析查询结果查看?

How to Return Parse Query results to view?

我正在使用 Parse javascript sdk,我正在尝试查询特定类名中的所有结果,然后 return 这些结果作为单个元素的列表显示在我的视图中。

示例:

 query.find({

   $rootScope.$apply(function () {

    //test 
    console.log(results[0].get("playerName"));

      //loop results
      for (var i = 0; i < results.length; i++) 
      { 

          blogs.push({
              title : results[i].get('playerName'),
              post : results[i].get('personalityType')
              });
       }

  //receive all blog objects in console
  console.log(blogs);
  
 
  //now try to display to view/page here
  document.write(blogs);

主要问题是,当我尝试从 document.write(博客);

如何进入这些对象?

blogs.title

blogs["title"]

blogs[0]

有什么想法吗?

试试这个以获得第一个值

blogs[0].title


    query.find({
$rootScope.$apply(function () {

    //test 
    console.log(results[0].get("playerName"));

      //loop results
      for (var i = 0; i < results.length; i++) 
      { 
        blogs[i]={}
        blogs[i].title = results[i].get('playerName');
        blogs[i].post  results[i].get('personalityType')

       }

  //receive all blog objects in console
  console.log(blogs);


  //now try to display to view/page here
  document.write(blogs);

这看起来成功了!谢谢,请往下看!我修改了您的回复并解决了我的大部分问题。

//Loops through all results
  for (var i = 0; i < results.length; i++) 
{ 
   //writes all results to page 
   document.write(blogs[i].title + " ");
   document.write(blogs[i].post + '</br>');
}

虽然我怎样才能去掉循环中的document.write?

我已经试过了

document.getElementById("demo").innerHTML