首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >测试环境ReferenceError: React is not defined,报错?

测试环境ReferenceError: React is not defined,报错?

提问于 2022-11-28 10:46:01
回答 0关注 0查看 115

React本地环境没有报错,后端部署到环境测试后就报错

项目中只是用了 fullcalendar这个日历插件后就有这个错

代码语言:js
复制
import React, { useEffect, useState } from "react";
import FullCalendar from "@fullcalendar/react";
import locale from "@fullcalendar/core/locales/zh-cn"; // 中文
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import { Button, message } from "antd";
import { serviceGetEqDeviceMaintPlanCalendar } from "@/services";
import "./index.scss";
// import "@fullcalendar/react/dist/vdom";

type Props = {
  setTabToggle: any;
};

const PlanCalendar: React.FC<Props> = function ({ setTabToggle }) {
  const [sourceList, setSourceList] = useState([]);
  const [getcalendarLoading, setGetcalendarLoading] = useState(false);

  const calendarContext = () => {
    serviceGetEqDeviceMaintPlanCalendar()
      .then((res: any) => {
        if (res.data.Tag) {
          setSourceList(res.data.Data);
        } else if (res.data.Message) {
          message.error(res.data.Message);
        }
      })
      .catch((err: any) => {
        console.log(err);
      })
      .finally(() => {
        setGetcalendarLoading(false);
      });
  };

  useEffect(() => {
    calendarContext();
  }, []);

  const onCancelPlan = (value: any) => {
    setTabToggle(value);
  };
  return (
    <div className="total
      <FullCalendar
        plugins={[dayGridPlugin, timeGridPlugin]}
        initialView="dayGridMonth"
        headerToolbar={{
          left: "prevYear,prev,next,nextYear today",
          center: "title",
          right: "timeGridWeek,dayGridMonth,timeGridYear",
        }}
        buttonText={{
          today: "今天",
          week: "周",
          month: "月",
          year: "年",
        }}
        events={sourceList}
        height="95%"
        locale={locale}
      />
    </div>
  );
};

export default React.memo(PlanCalendar);

我找了大小写,但是没有写错的,现在我也不知道为什么回报这个错了

下面是插件的版本

代码语言:js
复制
 "@fullcalendar/core": "^5.5.1",
    "@fullcalendar/daygrid": "^5.5.0",
    "@fullcalendar/react": "^5.5.0",
    "@fullcalendar/timegrid": "^5.5.1",

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档