如何在JavaScript中解码golang url.QueryEscape数据?

I have a string in JS side which is url.QueryEscaped.

Spaces were replaced with + sign by url.QueryEscape. They don't get converted back to space in decodeURIComponent. Should I manually do a string replace all + with space? What is the right way to decode it?

One simple method is to replace all the + characters with spaces prior to decoding. For example:

decodeURIComponent("%2f+%2b".replace(/\+/g, " "))

will correctly decode the string to "/ +". Note that it is necessary to perform the replacement prior to decoding, since there could be encoded + characters in the string.