gpt4 book ai didi

javascript - Parse.User.Login 不是函数?

转载 作者:行者123 更新时间:2023-11-30 12:13:39 25 4
gpt4 key购买 nike

我正在自学一些 Javascript 和 Parse.com。我正在关注此视频:https://www.youtube.com/watch?v=vB5lo9bx57s&list=PLoN_ejT35AEhbFswEKW36LxzyXJs7xCWS&index=6

这是代码。问题是我无法登录。当我尝试时,我在控制台中收到以下返回消息:

TypeError: Parse.User.LogIn is not a function

我有点迷茫,因为它显然是一个既适用于视频又适用于其他教程的功能。

<h1>Log In!</h1>

<form id="login">
<p><input id="login-name" type="text"></p>
<p><input id="login-password" type="password"></p>
<p><input id="login-submit" type="submit"></p>
</form>

<h1>Sign Up!</h1>
<form id="signup">
<p><input id="signup-name" type="text"></p>
<p><input id="signup-password" type="password"></p>
<p><input id="signup-submit" type="submit"></p>
</form>

<h1>You're ready to use Parse!</h1>

<form id="post-form">
<p><input id="post-title" type="text"></p>
<p><textarea id="post-content"></textarea></p>
<p><input type="radio" name="post-select" value="0" checked>Not Selected
<br><input type="radio" name="post-select" value="1">One
<br><input type="radio" name="post-select" value="2">Two
<br><input type="radio" name="post-select" value="3">Three
<br><input type="radio" name="post-select" value="4">Four
</p>
<p><input id="post-submit" type="submit"></p>
</form>

<ul id="list-posts">
<!--
<li>
<h3></h3>
<p></p>
</li>
-->
</ul>

Parse.initialize("abc", "123");

var Post = Parse.Object.extend("Post");

$("#login").submit(function(event){
event.preventDefault();

var name = $("#login-name").val();
var pass = $("#login-password").val();

Parse.User.LogIn(name, pass, {
success: function(user){
console.log("Log In Success!");
}, error: function(user, error){
console.log("Log In Error:"+error.message);
}
});
});

$("#signup").submit(function(event){
event.preventDefault();

var name = $("#signup-name").val();
var pass = $("#signup-password").val();

var user = new Parse.User();
user.set("username",name);
user.set("password",pass);

user.signUp(null, {
success: function(){
//
}, error: function(user, error){
console.log("signup error:"+error.message);
}
});
});

function getPosts() {
var query = new Parse.Query(Post);
query.find({
success: function(results) {
var output = "";
for (var i in results) {
var title = results[i].get("title");
var content = results[i].get("content");
var pselect = results[i].get("pselect");

output += "<li>";
output += "<h3>"+title+"</h3>";
output += "<p>"+content+"</p>";
output += "<p>"+pselect+"</p>";
output += "</li>";
}
$("#list-posts").html(output);
}, error: function(){
console.log("Query Error:"+error.message);
}
});
}

getPosts ();

$("#post-form").submit(function(event) {
event.preventDefault();
var title = $("#post-title").val();
var content = $("#post-content").val();
var pselect = $(":input[name=post-select]:checked").val();

var newPost = new Post();
newPost.set("title", title);
newPost.set("content", content);
newPost.set("pselect", pselect);

newPost.save({
success: function(){
getPosts ();
},
error: function(error){
console.log("Error:"+error.message);
}
});
});

最佳答案

Javascript 是区分大小写的语言。你需要使用

解析.User.logIn

而不是您提供的代码中的 Parse.User.LogIn。

关于javascript - Parse.User.Login 不是函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33047217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com