未捕获的ReferenceError: X未定义



所以我正在挖掘WebOS的enyo框架,我感到非常沮丧。我目前在我的日志中得到以下错误。我一直在看框架中的样本,我似乎找不到错误的来源。我已经有十多年没有做过任何HTML或js了,那时我所做的都是非常基础的东西。如有任何帮助,不胜感激

Uncaught ReferenceError: Learning is not defined, index.html:9

这是一个非常简单的应用程序,我目前只是试图让元素出现在屏幕上。

index . html

<!doctype html />
<html>
<head>
    <title>Learning</title>
    <script src="../../enyo/1.0/framework/enyo.js" type="text/javascript"></script>
</head>
<body>
    <script type="text/javascript">
       new MyApps.Learning().renderInto(document.body);
</script>
</body>
</html>

Learning.js

enyo.kind({
    name: "MyApps.Learning",
    kind: enyo.VFlexBox,
    components: [
        { kind: "Scrim",
            layoutKind: "VFlexLayout",
            align: "center",
            pack: "center",
            components: [
                {kind: "SpinnerLarge"}
            ]
        }
    ]
});

depends.js

enyo.depends(
    "source/Learning.js",
    "css/Learning.css"
);

appinfo.json

文件

{
    "id": "com.myapps.learning",
    "uiRevision": "2",
    "version": "1.0.0",
    "vendor": "kizelli",
    "type": "web",
    "main": "index.html",
    "title": "Learning"
}

我想这是你的appinfo中的一个问题。json文件…

保持id为:com.myapps.learning

但是你引用它为myapps。学习,尝试从appinfo中删除com.。或将其添加到您的类型定义和index.html

这通常出现在你在Learning.js中出错的时候。我不是很确定,但你可以试试:

enyo.kind({
    name: "MyApps.Learning",
    kind: enyo.VFlexBox,
    components: [
        {kind: "Scrim",
         layoutKind: "VFlexLayout",
         align: "center",
         pack: "center",
         components: [
                {kind: "SpinnerLarge"}
            ]
        }
    ]
});

根据我的经验,当enjoy .js的路径错误时,就会出现这个问题。我有一个旧的SDK/模拟器副本,所以在我从教程复制的路径中找不到enyo.js。升级SDK为我解决了这个问题,但您可能可以ssh到您的模拟器中以找到正确的路径。

如果enyo没有加载,它将无法创建任何类型(MyApps.Learning)。

我有点失望,没有错误记录当enyo没有找到或没有加载....

最新更新