错误:TypeError:无法调用undefined方法'replace' [英] error: TypeError: Cannot call method 'replace' of undefined

查看:420
本文介绍了错误:TypeError:无法调用undefined方法'replace'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此代码替换另一个子字符串:

I'm trying to replace a substring by another one using this code:

var body = 'Message: ' + req.query.message.replace('/(?:\r\n|\r|\n)/g', '<br/>');

但是,继续这样,我在该行收到此错误消息:

But, proceeding that way I get this error message on that line:

TypeError: Cannot call method 'replace' of undefined

我无法使用javascript找到解决方法。我发现的只与jQuery有关。

I wasn't able to find the solution to fix this using javascript. What I've found is related to only jQuery.

请问如何解决这个问题?

Any brilliant idea how to fix that, please?

推荐答案

这是说req.query.message是未定义的。你必须弄清楚为什么这是未定义的。

It's saying req.query.message is undefined. You have to figure out why that is undefined.

这篇关于错误:TypeError:无法调用undefined方法'replace'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆