会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132647个问题
WEB前端全系列/第十六阶段:React企业级项目/宜居(商城类)高级React实战项目 16楼

reactshizhan.zip

帮忙看看我这个,点了新增按钮无法改变store的值,好像是组件没有和stroe关联起来

WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 17楼
WEB前端全系列/第十六阶段:React企业级项目/宜居(商城类)高级React实战项目 19楼
WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 20楼
WEB前端全系列/第十六阶段:React企业级项目/宜居(商城类)高级React实战项目 22楼
WEB前端全系列/第十六阶段:React企业级项目/宜居(商城类)高级React实战项目 23楼
WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 24楼

image.png

WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 25楼

image.png


WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 26楼

image.png

WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 27楼

老师为什么create store 不能使用 会报错

后来我根据建议安装了 Redux Toolkit

但是还是不会使用  Redux Toolkit

 

@deprecated
We recommend using the configureStore method of the @reduxjs/toolkit package, which replaces createStore.

Redux Toolkit is our recommended approach for writing Redux logic today, including store setup, reducers, data fetching, and more.

For more details, please read this Redux docs page: https://redux.js.org/introduction/why-rtk-is-redux-today

configureStore from Redux Toolkit is an improved version of createStore that simplifies setup and helps avoid common bugs.

You should not be using the redux core package by itself today, except for learning purposes. The createStore method from the core redux package will not be removed, but we encourage all users to migrate to using Redux Toolkit for all Redux code.

If you want to use createStore without this visual deprecation warning, use the legacy_createStore import instead:

import { legacy_createStore as createStore} from 'redux'

@不推荐使用

我们推荐使用 @reduxjs/toolkit 包的 configureStore 方法,它取代了 createStore。


Redux Toolkit 是我们推荐的当今编写 Redux 逻辑的方法,包括存储设置、reducers、数据获取等。


有关更多详细信息,请阅读此 Redux 文档页面:https://redux.js.org/introduction/why-rtk-is-redux-today


Redux Toolkit 中的 configureStore 是 createStore 的改进版本,它简化了设置并有助于避免常见错误。


你今天不应该单独使用 redux 核心包,除非是为了学习目的。核心 redux 包中的 createStore 方法不会被删除,但我们鼓励所有用户迁移到对所有 Redux 代码使用 Redux Toolkit。


如果您想在没有此视觉弃用警告的情况下使用 createStore,请改用 legacy_createStore 导入:


从“redux”导入 { legacy_createStore as createStore}


“createStore”已弃用。ts(6385)

index.d.ts(375, 4):该声明曾在此处标注为已弃用。


WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 28楼

为什么我点击换页这个下拉菜单就会自动闭合

import React, { Component } from 'react'
import { Modal, Form, Input, Select, Radio, Dropdown, Space,Pagination } from 'antd'
import { icons } from '../../../components'



export default class ModleForm extends Component {
    constructor(props){
        super(props);
        this.state={
            currentIcons:icons.slice(0,10)
        }
    }
    formRef = React.createRef();
    onCancel = () => {
        this.props.dispatch({
            type: "hideModleForm"
        })
    }

    onSave = (values) => {
        console.log(values);
    }
    layout = {
        labelCol: { span: 4 },
        wrapperCol: { span: 20 }
    }
    render() {
        return (
            <Modal visible width={600} title={this.props.title}
                onCancel={this.onCancel}
                onOk={() => this.formRef.current.submit()}
            >
                <Form {...this.layout} ref={this.formRef} onFinish={this.onSave}>
                    <Form.Item label="父菜单">
                        {"无"}
                    </Form.Item>
                    <Form.Item label="菜单名称" name="name" rules={[{ required: true }]}>
                        <Input></Input>
                    </Form.Item>
                    <Form.Item label="访问路径" name="linkUrl" rules={[{ required: true }]}>
                        <Input></Input>
                    </Form.Item>
                    <Form.Item label="打开方式" name="openType" rules={[{ required: true }]}>
                        <Select>
                            <Select.Option value="1">当前窗口</Select.Option>
                            <Select.Option value="2">新窗口</Select.Option>
                        </Select>
                    </Form.Item>
                    <Form.Item label="图标" name="icon" rules={[{ required: true }]}>
                        <Dropdown trigger={['click']}
                            overlayStyle={{background:"#fff",padding:10}}
                            overlay={
                                <>
                                    <Radio.Group>
                                        <Space direction='vertical'>
                                            {this.state.currentIcons.map((ele, index) => {
                                                return (<Radio value={ele.name} >
                                                    {React.createElement(ele.renderFn)}
                                                    <span style={{ margin: 5 }} key={index}>{ele.name}</span>
                                                </Radio>)
                                            })}
                                        </Space>
                                    </Radio.Group>
                                    <div style={{textAlign:"right",padding:10}}>
                                        <Pagination showSizeChanger={false} 
                                        size="small" 
                                        total={icons.length}
                                        onChange={(page,pageSize)=>{
                                            this.setState({
                                                currentIcons:icons.slice(pageSize*(page-1),pageSize*page)
                                            })
                                        }}
                                        ></Pagination>
                                    </div>
                                </>
                            }>
                            <Input></Input>
                        </Dropdown>
                    </Form.Item>
                    <Form.Item label="权限" name="isOfAdmin" rules={[{ required: true }]}>
                        <Radio.Group>
                            <Radio value="1">仅超管可见</Radio>
                            <Radio value="2">不限</Radio>
                        </Radio.Group>
                    </Form.Item>
                    <Form.Item label="菜单名称" name="name" rules={[{ required: true }]}>
                        <Input></Input>
                    </Form.Item>
                </Form>
            </Modal>
        )
    }
}


WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 30楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637