小编Cod*_*ver的帖子

使用 create-react-app 构建后如何修复白屏?

我使用react-router-dom并构建了我的反应应用程序。当我在服务器上部署它时,我得到一个空白页面并且控制台是空的。

我的 App.js 是:

import React, { Component } from 'react';
import { Route, Switch, BrowserRouter} from 'react-router-dom';
import Agenda from './components/Agenda/Agenda';
import Planning from './components/Planning/Planning';
class App extends Component {
  render() {
    return (
      <div>
        <BrowserRouter  basename="/">
          <Switch>
            <Route exact path="/"  component={Agenda} />
            <Route path="/planning" component={Planning} />
          </Switch>
        </BrowserRouter>
      </div>
    );
  }
}

export default App;
Run Code Online (Sandbox Code Playgroud)

我的 index.js 是:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(
        <App/>
, document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)

我的 index.html …

build reactjs react-router create-react-app react-router-v4

14
推荐指数
6
解决办法
4万
查看次数

如何使用material-ui设置时钟(timePicker)的颜色?

我试图material-ui-time-picker为 material-ui 更改timeInput ( )时钟的颜色,但它没有改变。

我的代码是:

<TimeInput
        style ={heure}
        mode='24h'
        value={heureDebut}
        onChange={this.handleheureDChange}
        autoOk={true} 
        cancelLabel=""
        okLabel=""
        placeholder=""
        disableUnderline={true}  
        endAdornment={
            <InputAdornment position="end" style={{opacity:'0.4', marginLeft:'92px'}}>
            <IconButton><i style={{fontSize:'18px'}} className="zmdi zmdi-alarm" /></IconButton>
            </InputAdornment>
        }
                      

/>
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我得到:

在此处输入图片说明

但我希望蓝色将更改为 #0E6EB8

我怎样才能改变它?

javascript css reactjs material-ui

6
推荐指数
1
解决办法
9904
查看次数

如何使用ReactJS在列表上显示Select查询的结果?

我是ReactJS的新开发人员,我在前端使用ReactJS 、后端使用NodeJS以及关于数据库的MySQL开发一个表。

\n

我希望当我单击操作列上的查看按钮时,它将被重定向到另一个页面,该页面显示包含选择查询结果的列表,如下所示:

\n

在此输入图像描述

\n

ViewClient.js:

\n
class ViewClient extends Component {\n    constructor(props) {\n        super(props);\n        this.state = {\n            clients: [],\n            Code :1111\n        };\n        this.toggle = this.toggle.bind(this);\n        this.state = {\n            activeTab: \'1\',\n        };\n    }\n\n    toggle(tab) {\n        if (this.state.activeTab !== tab) {\n            this.setState({\n                activeTab: tab,\n            });\n        }\n    }\n    componentDidMount(Code) {\n        \n        axios({\n                method: "get",\n                url: "/app/viewclient/"+Code  ,\n                withCredentials: true,\n                headers: {\n                    "Access-Control-Allow-Origin": "*",\n                    "Content-Type": "application/json",\n                    Accept: "application/json"\n                }\n            })\n            .then(response => {\n                if (response …
Run Code Online (Sandbox Code Playgroud)

javascript mysql node.js reactjs axios

5
推荐指数
1
解决办法
2万
查看次数

如何通过反应将数据从对话框发送回父容器?

我有一个react-big-calendar(父容器),我还有一个选择,根据这个选择(医生姓名)获取日历的事件,当我点击它时我有一个按钮,对话框将be 出现(另一个组件),在这个对话框中,我有一个表单可以在选择后添加一个事件,当我发布我的 API 时,我将它保存在本地存储中,但是在刷新后添加的事件没有出现在我的日历上页面并重新选择医生姓名。但我想,当我点击保存按钮时,会直接添加到日历上,并且会出现在日历上。

我的日历代码是:

   import Popup from './Popup';
export default class Calendar extends Component {
constructor(props){
    super(props);
    this.state = {
      events : [],
      open: false,
}}
componentDidMount = () => {
    fetch(process.env.REACT_APP_API_BACKEND_YET+'get_liste_praticien.php')
      .then(Response => Response.json())
      .then(data => {
        this.setState ({ praticiens : data })
        localStorage.setItem('Liste de praticiens ', JSON.stringify(this.state.praticiens))
    })
}
fetchData = (nom,identifiant_user) => {
    this.setState({
      events: [],
      evtStorage:[],
      prevEvents:[], 
      evtBackend:[]
    })
      fetch(process.env.REACT_APP_API_BACKEND+'get_liste_planning')
        .then(Response => Response.json())
        .then(data => {
          let evts = data.ListeResult;
          for …
Run Code Online (Sandbox Code Playgroud)

javascript state dialog reactjs react-props

5
推荐指数
1
解决办法
3664
查看次数

如何使用reactjs修复“预期在箭头函数中返回值”?

我的 react-app 组件中有两个函数

componentDidMount() {
        if(Object.keys(this.props.praticiens).length>0)
            Object.keys(this.props.praticiens).map((praticien) => {
                if(this.props.praticiens[praticien].identifiant_user === getUrlParams(window.location.hash).identifiant_user)
                    this.setState({
                        praticien:this.props.praticiens[praticien].id_user
                    })
            })
    }

    handleChangePraticien = (praticien) => {
        this.setState({ praticien }, () => {
            Object.keys(this.props.praticiens).map((praticien) => {
                if(this.state.praticien === this.props.praticiens[praticien].id_user)
                    this.props.selectPraticienFunction(this.props.praticiens[praticien].identifiant_user);
            })
        })
    }
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我得到:

Line 26:64:  Expected to return a value in arrow function  array-callback-return
  Line 36:64:  Expected to return a value in arrow function  array-callback-return
Run Code Online (Sandbox Code Playgroud)

例如第 26Object.keys(this.props.praticiens).map((praticien) => {行在 componentDidMount上开始,第 36 行在 handleChangePraticien 函数上是同一行

我该如何解决?

javascript object reactjs eslint arrow-functions

5
推荐指数
4
解决办法
2万
查看次数

如何使用reactjs合并两个对象数组?

我有一个react-big-calendar,我想从后端获取本周的事件,从本地存储中获取其他周的事件。

我的代码是:

componentDidMount() {
    fetch("url")
    .then(Response => Response.json())
      .then(data => {
        let evts = data;
        for (let i = 0; i < evts.length; i++) {
          evts[i].start = moment(evts[i].start).toDate();
          evts[i].end = moment(evts[i].end).toDate();
          this.state.evt1.push(evts[i])
        }                   
        this.setState({
          evt1: evts,
          prevEvents : evts
        })
      }) 
      console.log(this.state.evt1)
      const cachedHits = JSON.parse(localStorage.getItem('Evènements')) 
      console.log(cachedHits)
      for (let j = 0; j <cachedHits.length; j++) {
        cachedHits[j].start = moment(cachedHits[j].start).toDate();
        cachedHits[j].end = moment(cachedHits[j].end).toDate();
        this.state.evt2.push(cachedHits[j])
      }
    this.setState( {
      evt2: this.state.evt2
  })
    this.setState({
      events: [...this.state.evt1, ...this.state.evt2]
    })
  console.log(this.state.events)
  }
Run Code Online (Sandbox Code Playgroud)

events …

javascript arrays local-storage reactjs react-big-calendar

2
推荐指数
2
解决办法
2万
查看次数

如何将所有反应大日历更改为法语?

我尝试添加culture='fr'BigCalendar,但是,我得到一个错误。

我的代码是:

   import moment from "moment";
    BigCalendar.momentLocalizer(moment);

        export default class Agenda extends Component {
    constructor(props){
        super(props);
        this.state = {
          events: [
            {
              title: 'Calendar 1',
              start: new Date(2019, 2, 19, 15, 0, 0), //03:00 PM
              end: new Date(2019, 2, 19, 16, 30, 0), //04:30 PM
            },
            {
              title: 'Calendar 2 ',
              start: new Date(2019, 2, 20, 12, 30, 0), //08:30 AM
              end: new Date(2019, 2, 20, 18, 0, 0), //18:00 PM      
            },
            {
              title: 'Calendar 3 …
Run Code Online (Sandbox Code Playgroud)

culture fullcalendar momentjs reactjs react-big-calendar

0
推荐指数
2
解决办法
4194
查看次数