以下是我用来设置状态的代码.
handleAddNewQuiz(event){
this.quiz = new Quiz(this.db, this.newQuizName, function(err, affected, value){
if(!err){
this.setState( { quiz : value}); // ERROR: Cannot read property 'setState' of undefined
}
});
event.preventDefault();
};
Run Code Online (Sandbox Code Playgroud)
Rven虽然成功创建了数据库,但我无法调用this.state,因为它始终未定义.
我试过了:
self = this;
handleAddNewQuiz(event){
this.quiz = new Quiz(this.db, this.newQuizName, function(err, affected, value){
if(!err){
self.setState( { quiz : value}); // ERROR: self.setState is not a function
}
});
event.preventDefault();
};
Run Code Online (Sandbox Code Playgroud)
但它仍然失败,尝试a = this和使用a.setState,仍然没有运气.
我怎么解决这个问题?
当我阅读最新 RestSharp 的 readme.txt 时:
*** IMPORTANT CHANGE IN RESTSHARP VERSION 103 ***
In 103.0, JSON.NET was removed as a dependency.
If this is still installed in your project and no other libraries depend on
it you may remove it from your installed packages.
There is one breaking change: the default Json*Serializer* is no longer
compatible with Json.NET. To use Json.NET for serialization, copy the code
from https://github.com/restsharp/RestSharp/blob/86b31f9adf049d7fb821de8279154f41a17b36f7/RestSharp/Serializers/JsonSerializer.cs
and register it with your client:
var client = new RestClient();
client.JsonSerializer …Run Code Online (Sandbox Code Playgroud) 我想将日期从例如1441065600转换为YYYYMMDD格式。我怎么做?
$temp = date("Y-m-d",1441065600);
$rel_date = date_format( $temp, "YYYYMMDD");
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了一个错误:
date_format()期望参数1为DateTimeInterface
这些是我所做的步骤:
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Run Code Online (Sandbox Code Playgroud)
这是终端日志(错误在这里):
$ sudo apt-get update
Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://id.archive.ubuntu.com/ubuntu jammy InRelease
Hit:3 http://id.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://id.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:5 https://download.docker.com/linux/debian jammy InRelease
Get:6 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 …Run Code Online (Sandbox Code Playgroud)