我是新来的反应。在我的反应应用程序中进行路由时,我收到一个错误(未找到模块:无法解析 'react-lodable') 。
这是我的代码:
路由.js:
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import React, { Component } from 'react';
import Loadable from 'react-loadable';
import './App.css';
const Loading = () => <div> Loading... </div>;
const Home=Loadable({
loader:()=>import('./components/home-component/Home'),
loading:Loading
});
const User=Loadable({
loader:()=>import('./components/user-component/User'),
loading:Loading
});
class App extends Component {
render() {
return (
<Router>
<Switch>
<Route exact path="/" component="Home" />
<Route path="/user" component="User" />
</Switch>
</Router>
);
}
}
export default App;