React-Router可以直接指向Express定义的路由,而不是渲染组件吗? [英] Can React-Router point directly to a route defined with Express instead of rendering a component?

查看:52
本文介绍了React-Router可以直接指向Express定义的路由,而不是渲染组件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用React-Router直接指向后端Express定义的路由,而不是渲染组件?我想返回响应中不包含HTML的有效JSON.

How I can use React-Router to point directly to a route defined with Express on the backend instead of rendering a component? I want to return valid JSON with no HTML included in the response.

推荐答案

React-Router仅处理React前端上的路由.

React-Router only handles routing on the React frontend.

React-Router无法指向后端的Express Route.

There is no way for React-Router to point to an Express Route on the back end.

React组件必须使用该API端点.

A React component would have to use that API endpoint.

为什么不直接手动点击端点.

Why not just hit the endpoint manually.

这篇关于React-Router可以直接指向Express定义的路由,而不是渲染组件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆