我在 Markdown 中有一個文本,我想在我的 react-app 中使用變數顯示它。
我試過這種方式:
<ReactMarkdown
children={contentMd}
renderers={{
someElement: {
instanceLabel: label,
sessionName: test,
mail: emailSupport,
adresse: adressePostale,
},
}}
/>
在我的 Markdown 文本中,我參考了這樣的變數:
outil de gestion par {{instanceLabel}}
但它不起作用...
有人有解決方案嗎?
謝謝。
uj5u.com熱心網友回復:
contentMd是一個string,而不是 JSX。您需要插入變數,例如這樣:
<ReactMarkdown
children={`outil de gestion par ${instanceLabel}`}
{...props}
/>
或者像這樣:
<ReactMarkdown
{...props}
>
{`outil de gestion par ${instanceLabel}`}
</ReactMarkdown>
uj5u.com熱心網友回復:
我解決了我的問題。
就像你說的 Tymek,contantMd 是一個字串,所以我使用了函式 replace(),僅此而已!!
感謝您的閱讀
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/398180.html
上一篇:根據不同的環境設定自定義標頭
