import React, { useState, Suspense, lazy } from "react";
import "./styles.css";
const Test = lazy(() => import("./pages/Test"));
export default function App() {
const [state, setState] = useState(false);
return (
<div className="App">
<button onClick={() => setState(true)}>动态加载</button>
<Suspense fallback={<div>loading...</div>}>{state && <Test />}</Suspense>
</div>
);
}