草庐IT

properties

全部标签

javascript - 未捕获的类型错误 : Cannot read property 'length' of undefined

我有一个插件可以访问许多元素的length属性。但是,javascript控制台指向jquery.min.js的第12行。我如何回溯以找到我的插件中有问题的行? 最佳答案 如果您使用缩小的脚本,任何调试器(例如完全最好的Firebug)都会向您显示相同的问题行,并且此信息毫无用处(缩小的脚本难以阅读和理解,并且它们写在一行中)。解决此类问题的几种方法:正如我之前所说:为了开发而不是缩小脚本,调试器会向您显示有意义的行,如果您幸运的话,您可以找到非常有用的开发人员评论。如果找不到完整版本的脚本,请使用像这样的unminifier:ht

javascript - jQuery 中的 "Uncaught TypeError: cannot read property ' 长度 ' of null"

我正在定义在我的HTML上按下按钮时发生的以下操作:$(document).ready(function(){$("#query").keydown(function(){//stuff$.get(url,function(result){console.log(result);varlist="";for(vari=0,l=result["results"].length;i'+result["results"][i]["label"]+'';}list="Herearesomeresults:"+list+"";});});到达“结果”的是一个JSON数组,格式如下:{"resul

javascript - 为什么 Angular 5 Transition 抛出 AppComponent.html :2 ERROR TypeError: Cannot read property 'forEach' of undefined

为什么Angular5会抛出这个错误?AppComponent.html:2ERRORTypeError:Cannotreadproperty'forEach'ofundefined我正在研究Angular动画的概念验证,我直接使用网站上的代码。我的组件如下所示:import{Component,OnInit}from'@angular/core';import{trigger,state,style,transition,animate,keyframes}from'@angular/animations';@Component({selector:'app-obj-list',te

javascript - 未捕获的类型错误 : Cannot read property 'injection' of undefined

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭4年前。Improvethisquestion升级到16.x后出现以下错误UncaughtTypeError:Cannotreadproperty'injection'ofundefinedatinjectTapEventPlugin(injectTapEventPlugin.js:23)ateva

javascript - 在 Javascript 中声明空对象属性的简写,有吗?

我需要在我的脚本中声明很多对象属性,我想知道是否有任何方法可以缩短它:Core.registry.taskItemSelected;Core.registry.taskItemSelected.id;Core.registry.taskItemSelected.name;Core.registry.taskItemSelected.parent;Core.registry.taskItemSelected.summary;Core.registry.taskItemSelected.description; 最佳答案 那行不行?Co

javascript - 类型错误 : Cannot read property 'Roboto-Regular.ttf' of undefined

尝试使用JSAPIPdfMake构建PDF:然后根据thisHelloworld,我跑:vardocDef={content:'ThisisansamplePDFprintedwithpdfMake'}pdfMake.createPdf(docDef).download('optionalName.pdf');我遇到了这个错误:UncaughtTypeError:Cannotreadproperty'Roboto-Regular.ttf'ofundefined是否需要Roboto-Regular.ttf文件?如果是,放在哪里? 最佳答案

javascript - 匿名函数中的 "this"?

在JohnResig的书“ProJavascripttechniques”中,他描述了一种使用以下代码生成动态对象方法的方法://CreateanewuserobjectthatacceptsanobjectofpropertiesfunctionUser(properties){//Iteratethroughthepropertiesoftheobject,andmakesure//thatit'sproperlyscoped(asdiscussedpreviously)for(variinproperties){(function(){//Createanewgetterfort

javascript - 如何轻松地将默认值为 true 的变量设置为 false?

我通常这样设置对象属性,//Booleanthis.listening=config.listening||true;但是config.listening不是真就是假,在这种情况下this.listening将永远是true因为如果config.listening为假则等于真。有没有更好的方法来设置这些boolean属性而无需执行if语句?javascript中是否有一个ifisset函数来检查它是否存在而不是它等于什么? 最佳答案 您可以像这样使用三元(条件)运算符:this.listening=config.listening=

javascript - 类型错误 : Cannot read property 'error' of undefined on React Chrome Extension

我正在使用React-Chrome-Reduxlibrary开发ReactChrome扩展我是第一次用这个开发,一直卡在错误中,不知道是什么原因。我的弹出式应用程序在运行时失败,并在控制台上显示以下错误消息:Errorineventhandlerfor(unknown):TypeError:Cannotreadproperty'error'ofundefined我尝试调试并在错误的确切位置设置断点:returnnewPromise(function(resolve,reject){chrome.runtime.sendMessage({type:_constants.DISPATCH_

javascript - javascript中的整数长度

愚蠢的提问时间!我知道在JavaScript中你必须将整数转换为字符串:varnum=1024;len=num.toString().length;console.log(len);我的问题是:为什么JavaScript中的整数没有getlength属性?它是不是经常使用的东西? 最佳答案 嗯,我不认为为数字提供长度属性会有帮助。关键是字符串的长度不会因更改其表示而改变。例如你可以有一个类似这样的字符串:varb="sometext";除非您实际更改字符串本身,否则它的长度属性不会更改。但数字不是这种情况。同一个数字可以有多种表示。