我正在学习 javafx 并且我已经完成了基础知识,所以现在我想做一个更复杂的项目。我在网上阅读了很多关于这个主题的指南,但是当每个类代表 1 个场景时,我找不到任何地方如何切换场景或更改根节点。
为了更好地理解这里是我项目的简化版本:
假设我有 3 个类 A、B 和 C:
public class A{
private Stage stage;
A(Stage stage){
this.stage = stage;
}
public void showGui(){
// This will make all elements, put them on scene and then set that scene to stage
}
public void callB(){
B b = new B(Stage);
b.showGui();
}
}
public class B{
private Stage stage;
B(Stage stage){
this.stage = stage;
}
public void showGui(){
// This will make all elements, put them on …Run Code Online (Sandbox Code Playgroud) 我在项目上工作,我发现奇怪的问题,jwt.sign函数不识别传递用户作为对象,但是当我在jwt.sign中创建新对象时,它工作正常.
如果从文本中难以理解的是代码:
var username = req.body.username;
var password = req.body.password;
User.getUserByUsername(username,(err, user)=>{
if(err)
throw err;
if(!user)
return res.json({success: false, msg: "User with username "+ username+" doesn't exist"});
User.comparePassword(password, user.password, (err, passwordsMatched) =>{
// Prints that user is type of object
console.log("Type of user: "+typeof(user));
if(err) throw err;
if(passwordsMatched){
// line bellow throws error that it expects object when I pass user
var token = jwt.sign(user, Config.secret, {expiresIn: 604800});
res.json({
success: true,
token: 'JWT '+token,
user: {
name : user.name,
username: …Run Code Online (Sandbox Code Playgroud)