我需要存储 JWT 令牌,该令牌是在有效用户通过 REST API 正确注册后登录时生成的。我阅读并找到了在客户端站点存储 JWT 的这些方法:本地存储、会话存储、cookie、HttpOnly cookie、浏览器内存(React 状态)。
需要建议以正确的方法存储 JWT,并且还可以访问某些 API 以使用 JWT 令牌作为 post 请求标头参数用户相关数据进行获取。
这是我的登录代码部分,此时我将 JWT 令牌存储到窗口对象,之前保存在本地存储上,但现在需要以除本地存储或 cookie 之外的其他方式安全存储。
const handleSubmitLogin = evt => {
evt.preventDefault();
var cart = new Cart();
var request = new NFRequest();
var response = request.api(HTTP_METHOD.POST, '/auth', {
'email_address': allValuesLogin.email_login,
'password': allValuesLogin.password_login,
'cart_list': cart.getCartPostData(),
});
response.then((res) => {
if (res.type === 'success') {
window.$token = res.data.token
setLoginSuccess('Successfully Login')
setTimeout(()=> {
setLoginSuccess('');
}, 3000)
cart.handle({ action_type: "RESET_ITEMS" });
Router.push('/account')
} else {
setLoginError('Wrong …Run Code Online (Sandbox Code Playgroud) <div>当我使用 Material ui 代码中的选项卡时效果很好,但是当我使用网格和排版自定义 TabPanel 时遇到此警告,我理解无法放置在内部的问题<p>,但需要在 TabPanel 内部进行自定义的解决方案。
我需要有这样的东西:
<TabPanel value={value} index={0}>
<Grid>
<Grid>Item One</Grid>
</Grid>
</TabPanel>
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的代码示例:
import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";
import AppBar from "@material-ui/core/AppBar";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
import Typography from "@material-ui/core/Typography";
import Box from "@material-ui/core/Box";
import Grid from "@material-ui/core/Grid";
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`} …Run Code Online (Sandbox Code Playgroud) 我在 next.js 项目中使用“react-slick”作为图像滑块。使用它时,控制台会为 DOM 元素上的“currentSlide”和“slideCount”道具显示此警告。
Warning: React does not recognize the `currentSlide` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `currentslide` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
in svg (created by ForwardRef(SvgIcon))
in ForwardRef(SvgIcon) (created by WithStyles(ForwardRef(SvgIcon)))
in WithStyles(ForwardRef(SvgIcon)) (created by ForwardRef)
in ForwardRef
in ForwardRef (at HomeProductsSegment.js:560)
in PrevArrow (created by InnerSlider)
in div …Run Code Online (Sandbox Code Playgroud)