javascript 如何解决 Less 错误“Uncaught (in promise) TypeError: Cannot read property '1' of null”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34012993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to resolve Less error "Uncaught (in promise) TypeError: Cannot read property '1' of null"
提问by Laxmi Salunkhe
Getting generic javascript error. Not able to resolve it, Can someone point out what steps should I take to debug this bug?
获取通用 javascript 错误。无法解决它,有人可以指出我应该采取哪些步骤来调试这个错误?
Getting this error Uncaught (in promise) TypeError: Cannot read property '1' of nullin less.js
file. I have created angular application which has some javascript plugins, Less is one of them.
收到此错误未捕获的(以诺)类型错误:无法读取空的特性“1”的less.js
文件。我创建了具有一些 javascript 插件的 angular 应用程序,Less 就是其中之一。
回答by William Rosenbloom
You are attempting to access a property (like a child member) of a JS object, but the JS object you are trying to access it from has evaluated to null
. Basically, if we refer to the JS object as bob
, you are trying to make a call to bob.1
. However bob
does not have a property called 1
. In fact, bob
does not have any properties: bob
has evaluated to null
.
您正在尝试访问 JS 对象的属性(如子成员),但您尝试从中访问它的 JS 对象已评估为null
. 基本上,如果我们将 JS 对象称为bob
,则您正在尝试调用bob.1
. 但是bob
没有名为 的属性1
。事实上,bob
没有任何属性:bob
已评估为null
。
When you make your call to bob.1
the computer wants to look at bob
's lexical scope to find something in there called 1
. However when the computer actually looks at bob
it finds that bob
's type is null
, and therefore bob
cannot have a property called 1
. It then tells you this through the error you received.
当你bob.1
对计算机进行调用时,想查看它bob
的词法范围以在那里找到一些叫做1
. 然而,当计算机实际查看bob
它时,它发现它bob
的类型是null
,因此bob
不能有一个被调用的属性1
。然后它通过您收到的错误告诉您这一点。
What you should do next is take a look at less.js
and try to find a method called promise
. Then look for any attempt to access a property called 1
from any object within that method. When you find the object from which you are trying to access the property 1
, you know that object is not being initialized for some reason. You should then look at how that object is supposed to be initialized in order to make any necessary corrections to your implementation or the less.js
file itself.
您接下来应该做的是查看less.js
并尝试找到一个名为promise
. 然后寻找任何尝试访问1
从该方法内的任何对象调用的属性。当您找到试图从中访问属性的1
对象时,您就知道该对象由于某种原因没有被初始化。然后,您应该查看该对象应该如何初始化,以便对您的实现或less.js
文件本身进行任何必要的更正。