我通过 facebookincubator/create-react-app 创建了一个 react.js + router v4 项目,并且我使用没有后端语言的 Apache 2 来运行我的项目。
我读过这个official doc :
Generating Dynamic Tags on the Server
Since Create React App doesn’t support server rendering, you might be wondering how to make tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this:
<!doctype html>
<html lang="en">
<head>
<meta property="og:title" content="__OG_TITLE__">
<meta property="og:description" content="__OG_DESCRIPTION__">
Then, on the server, regardless of the backend you use, you can read index.html into memory and replace OG_TITLE, OG_DESCRIPTION, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!
如果我使用 apache 运行我的项目没有任何后端语言,有没有办法生成动态标签?
谢谢。
最佳答案
我建议使用 Helmet,它可以轻松管理元数据:https://github.com/nfl/react-helmet
Helmet 使用爬虫的证明
关于javascript - 如何使用 react.js 在 Apache 服务器上生成动态 <meta> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47885656/