gpt4 book ai didi

javascript - 如何使用 react.js 在 Apache 服务器上生成动态 <meta> 标签

转载 作者:行者123 更新时间:2023-11-29 11:00:32 25 4
gpt4 key购买 nike

我通过 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 运行我的项目没有任何后端语言,有没有办法生成动态标签?

谢谢。

最佳答案

关于javascript - 如何使用 react.js 在 Apache 服务器上生成动态 &lt;meta&gt; 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47885656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com