简体   繁体   English

Webpack中的多个入口点

[英]Multiple entry point in webpack

I want to use multiple entry point for login like '/user/login' & '/admin/login' . 我想使用多个入口点进行登录,例如'/user/login''/admin/login' I am bit confused about this. 我对此有些困惑。 Should I use separate files for this, or IS there any way where I can use multiple entry point using the same file? 我应该为此使用单独的文件,还是可以使用同一文件使用多个入口点? I am using react.js 我正在使用react.js

React Router 4 is a great router for React that allows you to configure paths like this: React Router 4React的绝佳路由器,它允许您配置如下路径:

<BrowserRouter>
  <Switch>
    <Route path="/user/login" component={LoginComponent} />
    <Route path="/admin/login" component={LoginComponent} />
    <Route path="/blueberry/login" component={LoginComponent} />
    <Route path="/user/signin" component={LoginComponent} />
    <Route path="/admin/signin" component={LoginComponent} />
    <Route path="/blueberry/signin" component={LoginComponent} />
  </Switch>
</BrowserRouter>

You can also use RegEx to simplify: 您还可以使用RegEx简化以下操作:

<BrowserRouter>
  <Switch>
    <Route
      path="/(user|admin|blueberry)/(login|signin)"
      component={LoginComponent} />
  </Switch>
</BrowserRouter>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM