当我使用react-big-scheduler时,如何解决“ ReferenceError:宽度未定义”?

时间:2019-06-16 10:18:31

标签: javascript reactjs react-component react-big-calendar

我有我的 react js 客户端,并且我在资源事件中使用 react-big-scheduler 强>调度。一切正常,我的资源事件已从 API调用中正确获取。但随后突然发生了此错误。

**C:/Users/HP/Desktop/proj/node_modules/react-big-scheduler/lib/index.js:320
  
> 320 |   var schedulerContainerWidth = width - resourceTableWidth + 1;
  321 |   var schedulerWidth = schedulerData.getContentTableWidth() - 1;
  

但是错误出在我从未创建的上述 index.js 文件中。我 npm 已安装 react-big-scheduler,并且该文件夹包含许多文件。我也也没有进行任何更改。

这是我使用Schedular的 ComponentWillMount()

componentWillMount()
  {
    let today = moment().format(DATE_FORMAT);
    let schedulerData = new SchedulerData(today, ViewTypes.Week);
    schedulerData.localeMoment.locale('en');
   

    const token = localStorage.getItem("jwttoken");
     axios.post('http://localhost/Auth/api/validate.php',{"jwt":token}, {
     headers: {
      'Accept': 'application/json, text/plain, */*',
       'Content-Type': 'application/json'
      }} )
    .then(response =>
    {
    console.log(response.data);
    this.setState({vendor: response.data.data})
    const vid = response.data.data.VendorID;

    return axios.get('http://localhost/Auth/api/show_all_HR.php?VendorID='+vid, {
    headers: {
     'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/json'
     }} )
   .then(response =>
   {
   console.log(response.data);
   schedulerData.setResources(response.data);
   this.setState({
     AllHR :response.data,
     viewModel : schedulerData
    });
     console.log("I should be rendered at 1st",this.state.AllHR);
     console.log(vid);
   });
 });

  axios.get('http://localhost/Auth/api/show_one_HR_hours.php?VendorID=48', {
 headers: {
  'Accept': 'application/json, text/plain, */*',
   'Content-Type': 'application/json'
  }} )
.then(response =>
    { console.log(response.data);
      schedulerData.setEvents(response.data);
      this.setState({
        AllSlots : response.data,
        viewModel : schedulerData });
});

}

0 个答案:

没有答案