为什么用replace.("aaa", "bbb")会报错?
发布于 5 年前 作者 vdai 11633 次浏览 来自 问答

replace在逻辑层使用会报错,不能用吗?

Cannot read property 'replace' of undefined;at "pages/xxx/xxx" page getXXX function

TypeError: Cannot read property 'replace' of undefined

5 回复

确实是这样使用吖,为啥会报错呢?

明显是你的string没赋值。

是你语法 错误了好吗  看清楚点

replace.

replace 你这个单词后面出了个 “.” 

你确定你的obj是个string类型?

stringObject.replace(regexp/substr,replacement)
回到顶部