我的wordpress网站如下
我有一个原型反应JS应用程序,使用prototype,它有可能匹配这个URL映射内的react,这样我就不会失去SEO,我们在这些页面。我有成百上千的标签和猫。
我是一个新手ReactJS/Web开发人员。我正在考虑将wordpress站点移动到子域,然后在主域上提供reactJS应用程序。
问候,会感谢任何帮助。
发布于 2018-08-15 23:30:04
是的,您可以通过使用match对象来匹配这个URL映射。
这是我的示例,用于映射Posts、路由的URL。邮政路线:“https://youu-wp-site-here.com/wp-json/wp/v2/posts”
我假设您拥有来自WP站点的POSTS路由的wp Rest数据,以及您已经映射到您的React应用程序中的posts数据。
在我的主页上,我有以下两条路线:
<Route path={`${match.path}`} render={(props) => render={( invoke the component here ) => ()} />
<Route path={`${match.path}/:topicId`} render={() => ( invoke the component here )} />
这在渲染组件,在您的路线导航到单一的邮政。
<Link
className='btn btn-outline-success'
role='button'
to={`${match.url}/${post.title.rendered.replace(/\s+/g, '-').toLowerCase()}`}
>Read more →</Link>
这是这个-> https://github.com/jun20/React-JS-and-WP-Rest-API/tree/posts-api-and-blog-layout-FINAL的github回购
https://stackoverflow.com/questions/50899415
复制相似问题