Node-webkit:ReferenceError:_未定义

时间:2022-09-13 19:19:41

When I try to run my app with node-webkit I have error: Node-webkit: ReferenceError: _ is not defined. I think it is about Lo-dash, but on browser everything work fine. Here is my index.html code:

当我尝试使用node-webkit运行我的应用程序时出现错误:Node-webkit:ReferenceError:_未定义。我认为这是关于Lo-dash,但在浏览器上一切正常。这是我的index.html代码:

<!DOCTYPE html>
<html ng-app="viewer">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="css/font-awesome.css">
    <script src="components.min.js"></script>
    <script src="app.min.js"></script>
</head>
<body>
<div id="content"></div>
<div ui-view></div>
</body>
</html>

In components.min.js i have all components I need - lodash, angular etc. When I run it by browsers or appJS i haven't any error, only on node-webkit.

在components.min.js我有我需要的所有组件 - lodash,angular等。当我通过浏览器或appJS运行时我没有任何错误,只在node-webkit上。

2 个解决方案

#1


1  

Quite usually these reference errors arise when some script tries to reference another script which isn't loaded yet. Basically, the order in which you register your script matters. Script that is referenced should be registered before the script that uses it.

通常,当某些脚本尝试引用尚未加载的另一个脚本时,会出现这些引用错误。基本上,您注册脚本的顺序很重要。引用的脚本应在使用它的脚本之前注册。

A good explanation of this issue (although with JQuery's $ selectors instead of the lodash _), is in this article here: http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined.html.

这个问题的一个很好的解释(虽然jQuery的$选择,而不是lodash _),是本文在这里:http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined html的。

Thus I would check the order in which your .js files are registered and their dependencies.

因此,我会检查.js文件的注册顺序及其依赖关系。

#2


1  

This is an issue with Lo-dash. The current edge version seems to have a fix for it, see this thread

这是Lo-dash的问题。当前边缘版本似乎有一个修复它,请参阅此线程

A quick solutions seems to be to replace <script src="path_to_lodash.js"></script> with <script>require('lodash')</script>

一个快速的解决方案似乎是用

#1


1  

Quite usually these reference errors arise when some script tries to reference another script which isn't loaded yet. Basically, the order in which you register your script matters. Script that is referenced should be registered before the script that uses it.

通常,当某些脚本尝试引用尚未加载的另一个脚本时,会出现这些引用错误。基本上,您注册脚本的顺序很重要。引用的脚本应在使用它的脚本之前注册。

A good explanation of this issue (although with JQuery's $ selectors instead of the lodash _), is in this article here: http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined.html.

这个问题的一个很好的解释(虽然jQuery的$选择,而不是lodash _),是本文在这里:http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined html的。

Thus I would check the order in which your .js files are registered and their dependencies.

因此,我会检查.js文件的注册顺序及其依赖关系。

#2


1  

This is an issue with Lo-dash. The current edge version seems to have a fix for it, see this thread

这是Lo-dash的问题。当前边缘版本似乎有一个修复它,请参阅此线程

A quick solutions seems to be to replace <script src="path_to_lodash.js"></script> with <script>require('lodash')</script>

一个快速的解决方案似乎是用