我在react项目中有我的index.html页面如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bucard | Digital Business Card</title>
<meta name="title" content="Bucard | Digital Business Card">
<meta name="description" content="Bucard - Description for bucard" />
<meta property="og:title" content="Bucard | Digital Business Card" />
<meta property="og:image" content="http://m.digital-card.co.il/zedka/152/images/icon.png" />
<meta property="og:description" content="Bucard - Description for bucard" />
<meta property="og:url" content="https://bucard.co.il/" />
</head>
<body>
<div id="root"></div>
</body>
</html>
还有我的react-helmet部分,它存在于组件中,在 url 上有它自己的路径:
<Helmet>
<title>{"Digital card of " + this.state.card.Name}</title>
<meta name="title" content={"Digital card of " + this.state.card.Name} />
<meta name="description" content="Description for the react-helmet section" />
<meta property="og:title" content={"Digital card of " + this.state.card.Name} />
<meta property="og:image" content="http://m.digital-card.co.il/friedman/249/images/icon.png" />
<meta property="og:description" content="Description for the react-helmet section" />
<meta property="og:url" content={"https://bucard.co.il/digitalCard/" + this.state.card.ShortID} />
</Helmet>
现在,这里的问题是这里唯一替换的标签是 <title> 标签,但没有一个 <meta> 标签被替换。
我没有服务器端渲染,我有服务器端 (node.js) 和返回一些值的 json 的函数,我在我的react应用程序中渲染。
我搜索了将近 2 周,但还没有解决这个问题,这对我的项目非常重要。也尝试过放在data-react-helmet=true
不同的情况下,但仍然无法正常工作。
任何人都可以帮我解决这个问题吗?非常感谢 :)