react-router處理特殊字符#

遇到的問題
http://localhost:8088/user/current-conversation/GROUP@TGS#15S477ZGI
【GROUP@TGS#15S477ZGI】是羣組會話ID,可是這個會話ID裏面有#,#是url的特殊字符表示錨點,致使在詳情頁裏面取到的會話ID沒有#後面的部分this

解決方法:url

this.props.history.push(`/user/current-conversation/$
{encodeURIComponent(encodeURIComponent(conversation.conversationID))}
`);

兩次encodeURIComponent
在詳情頁裏面兩次decodeURIComponentcode

相關文章
相關標籤/搜索