使用javascript的replace函数的字符串语法错误

gad*_*adu 0 javascript string syntax node.js express

我想将一个电子邮件地址作为查询字符串传递,因此我在使用以下代码行发送之前对其进行编码:

var encoded = encodeURIComponent(email).replace('.' '%2E');
Run Code Online (Sandbox Code Playgroud)

显然这段时间应该无关紧要,但如果我以这种方式运行(我在节点上编码并使用express并使用res.render()调用),我一直得到"无法找到模块'com'"

真的不明白为什么在我的案例期间导致问题,但无论哪种方式,这是我得到的确切错误:

    var encoded = encodeURIComponent(email).replace('.' '%2E');
                                                        ^^^^^
SyntaxError: Unexpected string
Run Code Online (Sandbox Code Playgroud)

Ale*_*yne 6

真的不明白为什么在我的情况下会导致问题

这不是一个时期的存在.这是缺少逗号.

var encoded = encodeURIComponent(email).replace('.', '%2E');
//                                                 ^ this here
Run Code Online (Sandbox Code Playgroud)