我正在从一个 api 获取数据,我希望其中一些数据的内容位于头盔内的元标记中(react-helmet-async),但是无论如何它都会返回空字符串。如果我静态地写一些文本,没关系,它也适用于标题,但不适用于 og 标签
<Helmet>
<meta property="og:type" content="WebSite" />
<meta property="fb:app_id" content="440924728203663"/>
<meta property='og:title' content={exactNews.title}/>
<meta property="og:url" content={window.location.href}/>
<meta property="og:description" content=""></meta>
<meta property="og:image" content={exactNews.title ? `https://khulo.gov.ge/${exactNews.img}` : "alt"}/>
<title>
{ language == 1 ? exactNews.geo.title ? exactNews.geo.title : "" : ""}
{ language == 2 ? exactNews.eng.title ? exactNews.eng.title : "" : ""}
</title>
</Helmet>
,就像我说的 - 标题有效,但 og 标签是空的(见下图)
我猜是因为这个库的异步特性?有关如何使其工作的任何提示?我尝试使用 ternery 运算符进行渲染,但没有。