我有一個字符串,其中有一個<a> text </a>標簽,但當它顯示在 ReactJS 的元素內時,瀏覽器只是將其讀取為純文本,這是我的示例代碼const datas = [ { title: 'the title1', description: `the link was in <a href="#">here</a>, please click` }, { title: 'the title2', description: `the link was in the last <a href="#">word</a>` }]const renderDatas = () => { return datas.map(data => { return ( <div> {data.description} </div> ) })}我已經在這里嘗試了接受的答案,唯一的區別是,我使用的是字符串文字(`),但它也只能由瀏覽器以純文本形式讀取。我的預期結果是當瀏覽器讀取它時使其成為<a href="#">here</a>可點擊的鏈接。
如何將字符串部分更改為JSX元素?
明月笑刀無情
2023-09-14 20:37:10