节点webkit:ReferenceError:_未定义

Node-webkit: ReferenceError: _ is not defined

本文关键字:未定义 ReferenceError 节点 webkit      更新时间:2023-09-26

当我尝试使用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>

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

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

本文对这个问题有一个很好的解释(尽管使用JQuery的$选择器而不是lodash_):http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined.html.

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

这是Lo短划线的问题。当前的边缘版本似乎有一个修复程序,请参阅这个线程

一个快速的解决方案似乎是用<script>require('lodash')</script> 取代<script src="path_to_lodash.js"></script>