let str = decodeURI(location.href).slice(index + 7).split('&')[0]
this.searchValProps = str
str = location.href.slice(index + 7).split('&')[0]
this.searchValProps = decodeURIComponent(str).trim()
对比以上两个this.searchValProps的区别:
decodeURIComponent得到的可能含特殊符号,不是理想的值,在做搜索功能时可能会搜索不出来。decodeURI则不会。

本文探讨了在JavaScript中使用decodeURIComponent与decodeURI的区别。前者可能会导致含有特殊符号的字符串无法进行理想搜索,而后者则不会出现此问题。这对于实现网页上的搜索功能尤其重要。
1499

被折叠的 条评论
为什么被折叠?



