[英]Uncaught TypeError: undefined is not a function
I have a script that pulls json data and converts it to a readable format. 我有一个脚本,可提取json数据并将其转换为可读格式。
It is returning the error: Uncaught TypeError: undefined is not a function
on the line container.append($.nano(template, events[0]));
它返回错误:
Uncaught TypeError: undefined is not a function
行container.append($.nano(template, events[0]));
上的Uncaught TypeError: undefined is not a function
container.append($.nano(template, events[0]));
I have tried to find answers on stackoverflow which include: 我试图找到关于stackoverflow的答案,包括:
I have done all of the above and have replicated the problem in this jsfiddle 我已经完成了上述所有工作,并在此jsfiddle中复制了问题
You're calling nano incorrectly, it's not a method of jQuery. 您错误地调用了nano,这不是jQuery的方法。 It should be like this (from the documentation ):
应该是这样的(来自文档 ):
container.append(nano(nogig));
nano is on line 244 in the fiddle. I'm not sure where I'm not defining it.
On that line, you have this: 在那一行上,您有:
function nano(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
var keys = key.split("."),
v = data[keys.shift()];
for (var i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
return (typeof v !== "undefined" && v !== null) ? v : "";
});
}
This is defined on the global scope, so change $.nano
to nano
. 这是在全局范围内定义的,因此将
$.nano
更改为nano
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.