所以我有一个 django-react 应用程序,其中使用 django-rest-framework 令牌身份验证包。我将从 API 调用中获取令牌并将其插入到一个钩子 (useCookies) 中,该钩子将作为 cookie 存储。我的代码如下:
import { useCookies } from "react-cookie";
const Home = () => {
const[token, setToken, removeToken] = useCookies(['loginToken']);
}
const loginBtn = () => {
APIService.LoginUser({
username: username,
password: password,
})
.then((response) => {
setToken("loginToken", response.token);
})
.catch((error) => console.log(error));
};
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试创建一个注销功能,用户只需按注销按钮即可注销。到目前为止我所拥有的是:
const logout = () => {
removeToken(['loginToken']);
}
Run Code Online (Sandbox Code Playgroud)
当按下按钮时,它会将我的 cookie 的值变为未定义。 前
loginToken: 'asd99123jsd9asd9231'
Run Code Online (Sandbox Code Playgroud)
后
loginToken: 'undefined'
Run Code Online (Sandbox Code Playgroud)
从我读到的文档来看,它应该完全删除cookie,甚至不留下cookie变量。我在这里可能会错过什么?预先非常感谢您。如果您需要更多信息,我非常乐意为您提供,请耐心等待,因为这是我的第一个 React 项目。
最初,我将我的 React 应用程序(使用 create-react-app 创建)部署到了 Github Pages,并且运行良好。但是,对文件进行一些更改后src,我想更新网站,因此我决定使用重新部署应用程序npm run deploy,并Published在命令末尾打印它。在 Github 上,操作显示构建成功,但无法部署,错误代码为 400。
来自Github的完整错误日志如下:
Actor: github-pages[bot]
Action ID: 1996792679
Artifact URL: https://pipelines.actions.githubusercontent.com/P4vIRQYdOzrk38NoGmJNrF5GvwW7S92VAUyJNinMXyLtZzPbIB/_apis/pipelines/workflows/1996792679/artifacts?api-version=6.0-preview
{"count":1,"value":[{"containerId":354579,"size":3092480,"signedContent":null,"fileContainerResourceUrl":"https://pipelines.actions.githubusercontent.com/P4vIRQYdOzrk38NoGmJNrF5GvwW7S92VAUyJNinMXyLtZzPbIB/_apis/resources/Containers/354579","type":"actions_storage","name":"github-pages","url":"https://pipelines.actions.githubusercontent.com/P4vIRQYdOzrk38NoGmJNrF5GvwW7S92VAUyJNinMXyLtZzPbIB/_apis/pipelines/1/runs/2/artifacts?artifactName=github-pages","expiresOn":"2022-06-15T05:21:40.7473658Z","items":null}]}
Creating deployment with payload:
{
"artifact_url": "https://pipelines.actions.githubusercontent.com/P4vIRQYdOzrk38NoGmJNrF5GvwW7S92VAUyJNinMXyLtZzPbIB/_apis/pipelines/1/runs/2/artifacts?artifactName=github-pages&%24expand=SignedContent",
"pages_build_version": "8e6a4594c3e946a3f32ab67af68f527ec66ffc90",
"oidc_token": "***"
}
Failed to create deployment for 8e6a4594c3e946a3f32ab67af68f527ec66ffc90.
{"message":"Deployment request failed for 8e6a4594c3e946a3f32ab67af68f527ec66ffc90 due to in progress deployment. Please cancel c1852e5059b99567d48405d0610990fdc25f0946 first or wait for it to complete.","documentation_url":"https://docs.github.com/rest/reference/repos#create-a-github-pages-deployment"}
Error: Error: Request failed with status code 400
Error: Error: Request failed with status …Run Code Online (Sandbox Code Playgroud) 如何在 SVG 中对渐变颜色的填充进行动画处理?我希望填充从不透明度 0 操作到不透明度 1。
.header-anim {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
#logo-anim path:nth-child(1) {
stroke-dasharray: 1032;
stroke-dashoffset: 1032;
animation: line-anim 2s ease forwards, fill-black 0.5s ease forwards 2s;
}
#logo-anim path:nth-child(2) {
stroke-dasharray: 1056;
stroke-dashoffset: 1056;
animation: line-anim 2s ease forwards, fill-gradient 0.5s ease forwards 2s;
}
@keyframes line-anim {
to {
stroke-dashoffset: 0;
}
}
@keyframes fill-black {
from {
fill: transparent;
}
to {
fill: black;
}
}
@keyframes fill-gradient {
from …Run Code Online (Sandbox Code Playgroud)