2016-05-16 11 views
0

エラーが発生しました:このEnyoアプリケーションをローカルホストにロードすると、JSコンソールで「Uncaught referenceError:Appが定義されていません。私はEnyoの新しいブランドなので、種類やコンポーネントの概念を学びたいと思っています。 (ソース・フォルダ内)Enyoエラー:「Uncaught referenceError:Appが定義されていません」

app.js:(ルートフォルダ内)

enyo.depends(
// Layout library 
"$lib/layout", 
// Onyx UI library 
"$lib/onyx", // To theme Onyx using Theme.less, change this line to $lib/onyx/source, 
//"Theme.less", // uncomment this line, and follow the steps described in Theme.less 
// CSS/LESS style files 
"../assets/css/app.css", 
// Include our default entry point 
"App.js", 
"Page2.js" 
); 

index.htmlを:(ソース・フォルダ内)

enyo.kind({ 
name: "App", 
kind: "FittableRows", 
classes: "enyo-fit enyo-unselectable", 
components: [ 
     { 
     kind: "onyx.Toolbar", 
     layoutKind:"FittableColumnsLayout", 
     components: [ 
      { 
       kind:onyx.Button, 
       style:"width:80px;background:green;", 
       ontap:"handleBtnBack", 
       content:"Back" 
      }, 
      { 
       content:"Header", 
       style:"text-align:center;", 
       fit:true 
      }, 
      { 
       kind:onyx.Button, 
       style:"width:80px;background:red;", 
       ontap:"handleBtnNext", 
       content:"Next" 
      } 
     ] 
    }, 
    { 
     kind: "Scroller", 
     horizontal:"hidden", 
     touch:true, 
     fit:true, 
     thumb:true, 
     components:[ 
     { 
       tag:"h1", 
       //This is how we insert css class. 
       classes:"padding15px", 
       content:"This is content area...Hello World!!!" 
      } 
     ]    
    }, 
    { 
     kind: "onyx.Toolbar", 
     // The footer 
     layoutKind:"FittableColumnsLayout", 
     components:[ 
      { 
        kind:"onyx.Button", 
        content:"Go Next Page", 
        ontap:"handleBtnNextPage", 
        fit:true 
      } 
     ] 
    } 
], 
create: function(){ 
    this.inherited(arguments); 
    console.log("App is created in memory"); 
}, 
rendered : function(){ 
    this.inherited(arguments); 
    console.log("App is created in rendered into DOM"); 
}, 
    handleBtnNextPage : function(inSender,inEvent){ 
     new Page2().renderInto(document.body); 
    }, 
    handleBtnNext: function(inSender,inEvent){ 
     new Page2().renderInto(document.body); 
    }, 
    handleBtnBack: function(inSender,inEvent){ 
     //For each enyo event handler comes with inSender, the control that sends the event and the inEvent the actual event itself. 
     alert("Back Button"); 
    } 
}); 

package.js

<!--My Copy--> 

    <!DOCTYPE html> 
    <html> 
    <head> 
     <title>IsGoodStuff.com Tutorial #2</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> 

     <link rel="shortcut icon" href="assets/favicon.ico"/> 

     <script src="enyo/enyo.js" type="text/javascript"></script> 

     <!-- --> 
     <script src="package.js" type="text/javascript"> </script> 

    </head> 
    <body> 
     <script type="text/javascript"> 
     new App().renderInto(document.body); 

     </script> 
    </body> 
    </html> 

答えて

0

index.htmlがルートフォルダにあり、メインのpackage.jsがソースフォルダにある場合、おそらくpackage.jsを読み込むスクリプトタグです。試してください:

<script src="source/package.js" type="text/javascript"> </script> 
0

あなたはPage2を提供していませんが、コードはそのまま動作するようです。ここで

が作業ページを示すフィドルです:http://jsfiddle.net/kgxvg7Lw/1/

いくつかの考え:

1)あなたは、大文字と小文字が区別されるファイルシステムを使用していますか? app.jsと表示されますが、package.jsにはApp.js(大文字)が表示されます。 2)コンソールに解析エラーがないことは確かですか?

さて、それは...おそらく、すべての「ページ」切り替えごとに新しいアプリをリロードしたくないということです。通常は、パネルに表示されるコンテンツを制御し、必要に応じてパネル間を移動するために、Panelのようなものを使用します。

関連する問題