解决build失败

This commit is contained in:
hujinwei
2022-11-30 20:13:35 +08:00
parent 033015ae36
commit d70b4460af
2 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,6 @@ import NavMenu, {MenusProp} from "./components/NavMenu/NavMenu";
import CodeEditor from "./components/CodeEditor/CodeEditor"; import CodeEditor from "./components/CodeEditor/CodeEditor";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import "./index.css"; import "./index.css";
import { useParams } from "react-router-dom";
function Demo() { function Demo() {

View File

@ -1,7 +1,7 @@
import "./index.css"; import "./index.css";
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'; import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
import {useEffect, useRef, useState} from "react"; import {useEffect, useRef, useState} from "react";
import {Routes, Route, Link, useParams} from 'react-router-dom'; import { Link, useParams } from 'react-router-dom';
interface MenuProp { interface MenuProp {
title: string; title: string;
@ -21,13 +21,6 @@ function Examples() {
const iframeRef = useRef<HTMLIFrameElement>(); const iframeRef = useRef<HTMLIFrameElement>();
const { id } = useParams(); const { id } = useParams();
const getCode = (url: string) => {
if (!url) return;
fetch(url, {mode: 'cors'}).then(data => data.text()).then((data) => {
run(data);
})
}
const run = (code: string) => { const run = (code: string) => {
const preview = document.querySelector("#preview") as HTMLElement; const preview = document.querySelector("#preview") as HTMLElement;
preview.innerHTML = ""; preview.innerHTML = "";
@ -40,6 +33,13 @@ function Examples() {
} }
} }
const getCode = (url: string) => {
if (!url) return;
fetch(url, {mode: 'cors'}).then(data => data.text()).then((data) => {
run(data);
})
}
useEffect(() => { useEffect(() => {
fetch("./config.json").then(data => data.json()).then((data) => { fetch("./config.json").then(data => data.json()).then((data) => {
const indexMenus:string[] = []; const indexMenus:string[] = [];
@ -64,6 +64,7 @@ function Examples() {
} }
}); });
}); });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id, data]) }, [id, data])