如何从parse.com数据库中显示内容?请给我代码。我只是学习js。例如,如何显示所有用户。或者如何显示有关一个用户的信息。请帮助)
答案 0 :(得分:1)
您好我建议您开始学习解析ans JS并提供所有适当的文档。 Documentations
如果您正在寻找使用Parse和JS的简单示例,请查看以下代码
myObject.fetch({
success: function(myObject) {
// The object was refreshed successfully.
},
error: function(myObject, error) {
// The object was not refreshed successfully.
// error is a Parse.Error with an error code and message.
}
});
或者您也可以参考下面的示例,我们可以使用handlebar.js来显示每个博客对象。
$(function() {
Parse.$ = jQuery;
// Replace this line with the one on your Quickstart Guide Page
Parse.initialize("KEYS", "KEYS");
// Your Parse application key
var Blog = Parse.Object.extend("Blog");
var Blogs = Parse.Collection.extend({
model: Blog
});
var blogs = new Blogs();
blogs.fetch({
success: function(blogs){
console.log(blogs);
var blogsView = new BlogsView({ collection: blogs });
blogsView.render();
$('.main-container').html(blogsView.el);
},
error: function(blog, error){
console.log(error);_
}
});
var BlogsView = Parse.View.extend({
template: Handlebars.compile($('#blogs-tpl').html()),
render: function(){
var collection = { blog: this.collection.toJSON() };
this.$el.html(this.template(collection));
}
});
});