[英]TypeError: this.func is not a function in Node.js
I'm writing a node.js application which uses functions from an imported JSON file.我正在编写一个 node.js 应用程序,它使用来自导入的 JSON 文件的函数。 I also wanted to reuse some functions inside the file.
我还想重用文件中的一些函数。 I tried to access them with
this.functionName
but it just returns TypeError: this.functionName is not a function
.我尝试使用
this.functionName
访问它们,但它只返回TypeError: this.functionName is not a function
。 Can someone explain why this occurs and how to fix it?有人可以解释为什么会发生这种情况以及如何解决吗? Thanks
谢谢
On another hand, if your function is a standard string you can do something like this, your function is in my case (x+1):另一方面,如果您的 function 是标准字符串,您可以这样做,您的 function 在我的情况下是(x+1):
var x=1; var inc = eval('x + 1'); console.log(inc)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.