我试图理解kirasoft的 react-starter-kit并注意到他们的路由有两个用于“*”通配符路由的条目。为什么有两个,优先顺序是什么?第一条路线似乎设置了整个应用程序,然后第二条路线似乎触发了默认的内容处理程序......都被触发了,如果是这样,两者之间的逻辑是什么,它们是否都只是按顺序触发并被附加以某种方式一起响应?
import React from 'react';
import Router from 'react-routing/src/Router';
import http from './core/HttpClient';
import App from './components/App';
import ContentPage from './components/ContentPage';
import ContactPage from './components/ContactPage';
import LoginPage from './components/LoginPage';
import RegisterPage from './components/RegisterPage';
import NotFoundPage from './components/NotFoundPage';
import ErrorPage from './components/ErrorPage';
const router = new Router(on => {
on('*', async (state, next) => {
const component = await next();
return component && <App context={state.context}>{component}</App>;
});
on('/contact', async () => <ContactPage />);
on('/login', async () => <LoginPage />);
on('/register', async () => <RegisterPage />);
on('*', async (state) => {
const content = await http.get(`/api/content?path=${state.path}`);
return content && <ContentPage {...content} />;
});
})