账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    react中,我想让下面这段代码读取cookie的值,如果cookie值变化了,页面div可以显示出来
    37
    0
    import React from 'react'
    import './style.css'
    
    /**
     * 功能:默认设置界面
     */
    
    
    class RightList extends React.Component {
        constructor(props) {
            super(props);
    
            this.state = {
                show : true
            };
        }
    
    
        componentDidMount() { // 初始化render之后只执行一次
    
            //console.log('定时器结尾');
            document.getElementById('parent').style['fontSize'] = '85px';
    
        }
    
    
        render() {
    
            return (
                <div id='parent'  >
                    开启
                </div>
            )
        }
    }
    
    
    export default RightList;
    
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • AI智能解答 超级管理员 2023-04-06 12:121楼
      ``` import React, { useState, useEffect } from 'react'; function App() { const [cookieValue, setCookieValue] = useState(''); useEffect(() => { const cookieValue = document.cookie.split('=')[1]; setCookieValue(cookieValue); }, []); return (
      {cookieValue}
      ); } export default App; ``
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部