2016-07-18 5 views
0

私は基本的に蒸気APIを使用してログインボタンを持つブートストラップnavbarを持っています。私は流星;どのように私はこの作業を行うには、鉄道+テンプレートの問題

C:\Users\Farhan\AppData\Local\.meteor\packages\meteor-tool\1.3.4_4\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280 
         throw(ex); 
          ^ReferenceError: Template is not defined 
    at meteorInstall.lib.main.js (lib/main.js:1:1) 
    at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1) 
    at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1) 
    at C:\Users\Farhan\csgofiyav1\.meteor\local\build\programs\server\app\app.js:68:1 
    at C:\Users\Farhan\csgofiyav1\.meteor\local\build\programs\server\boot.js:297:10 
    at Array.forEach (native) 
    at Function._.each._.forEach (C:\Users\Farhan\AppData\Local\.meteor\packages\meteor-tool\1.3.4_4\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11) 
    at C:\Users\Farhan\csgofiyav1\.meteor\local\build\programs\server\boot.js:133:5 Exited with code: 8 Your application is crashing. Waiting for file change. 

と私のエラーとして返されます。私のコードは次のとおりです。main.js

Template.layoutDefault.events({ 
    'click .steamLogin': function(event){ 
     Meteor.loginWithSteam(); 
    } 
}); 

とlayoutDefault.html

<template name="layoutDefault"> 
    .. 
         <a class="steamLogin" href="#">Login With Steam</a> 
        </li> 
       </ul> 
      </div> 
      <!-- /.navbar-collapse --> 
     </div> 
     <!-- /.container --> 
    </nav> 
    {{> yield}} 
    </template> 

routes.js

Router.configure({ 
    layoutTemplate: 'layoutDefault' 
}); 

Router.route('/', { 
    template: 'main' 
}); 

Router.route('/contact', { 
    template: 'contact' 
}); 

感謝任意の助けを!

+0

main.jsが/ importsの下にある場合は、インポートする必要があります(遅延ロードされません)。これがTemplateが定義されていない理由かもしれません。 Add:import {Template} from 'meteor/templating' – Felix

+0

ありがとう、更新された質問 – Farhan

答えて

0

エラーは、もはや今言い、存在するが、

Unable to resolve some modules: 

    "./layoutDefault.html" in /C/Users/Farhan/csgofiyav1/client/main.js 
(web.browser) 

shfitedクライアントフォルダにmain.js

クライアント/ main.js

import { Template } from 'meteor/templating'; 

import './templates/layout/layoutDefault.html'; 

Template.layoutDefault.events({ 
    'click .steamLogin': function(event){ 
     Meteor.loginWithSteam(); 
    } 
}); 

クライアント/テンプレート/ layout/layoutDefault.html

<template name="layoutDefault"> 
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
     ..... 
        <li> 
         <a class="steamLogin" href="#">Login With Steam</a> 
        </li> 
       </ul> 
      </div> 
      <!-- /.navbar-collapse --> 
     </div> 
     <!-- /.container --> 
    </nav> 

    {{> yield}} 
    </template> 
+0

HTMLファイルをインポートする必要はありません。 – Felix

0

これで問題なく動作します。私は、サーバー側はテンプレートのためのイベントを持つのではなく、その後

を追加しました。この

if(Meteor.isServer) { 
    Meteor.startup(function() { 
    ServiceConfiguration.configurations.upsert(
     { service: 'steam' }, 
     { 
     $set: { 
      loginStyle: 'redirect', 
      timeout: 10000 // 10 seconds 
     } 
     } 
    ); 
    }); 
} 

をmain.js更新しなければならなかった、私は、どこのクライアント側のjsにlogin.htmlとへのリンクをルーティングされている一回テンプレートがレンダリングされたら、Meteor.loginWithSteam()を実行します。

Template.login.rendered = function() { 
    if(!this._rendered) { 
     this._rendered = true; 
     Meteor.loginWithSteam(); 
    } 
} 
関連する問題