2013-10-09 34 views
0

這裏完全基本的例子,是我的項目結構:流星0.6.5 - 與帳戶的用戶界面的自舉,下拉不工作

├── app.html 
├── app.js 
├── packages/ 
│   └── accounts-ui-bootstrap-dropdown -> /Users/jon/.meteorite/packages/accounts-ui-bootstrap-dropdown/erobit/meteor-accounts-ui-bootstrap-dropdown/c8b29d2e7f8611d6dec9d6d23c1c2b94e000b0fb/ 
├── smart.json 
└── smart.lock 

'流星列表--using」給出瞭如下結果:

standard-app-packages 
autopublish 
insecure 
preserve-inputs 
accounts-ui-bootstrap-dropdown 
bootstrap 
accounts-password 

app.html如下:

<head> 
    <title>app</title> 
</head> 

<body> 
    {{> header}} 
</body> 

<template name="header"> 
    <header class="navbar"> 
     <div class="navbar-inner"> 
      <div class="nav-collapse collapse"> 
       <ul> 
        <li>{{loginButtons}}</li> 
       </ul> 
      </div> 
     </div> 
    </header> 
</template> 

app.js如下:

Accounts.ui.config({ passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL' }); 

我收到以下錯誤,當我嘗試啓動應用程序:

[[[[[ ~/dev/app ]]]]] 

=> Meteor server running on: http://localhost:3000/ 
W202309-16:30:21.275(-4)? (STDERR) /Users/jon/.meteor/tools/3cba50c44a/lib/node_modules/fibers/future.js:173 
W202309-16:30:21.365(-4)? (STDERR)      throw(ex); 
W202309-16:30:21.365(-4)? (STDERR)       ^
W202309-16:30:21.366(-4)? (STDERR) TypeError: Cannot call method 'config' of undefined 
W202309-16:30:21.366(-4)? (STDERR)  at app/app.js:1:48 
W202309-16:30:21.366(-4)? (STDERR)  at app/app.js:24:3 
W202309-16:30:21.367(-4)? (STDERR)  at mains (/Users/jon/dev/app/.meteor/local/build/programs/server/boot.js:153:10) 
W202309-16:30:21.367(-4)? (STDERR)  at Array.forEach (native) 
W202309-16:30:21.367(-4)? (STDERR)  at Function._.each._.forEach (/Users/jon/.meteor/tools/3cba50c44a/lib/node_modules/underscore/underscore.js:79:11) 
W202309-16:30:21.367(-4)? (STDERR)  at /Users/jon/dev/app/.meteor/local/build/programs/server/boot.js:80:5 
=> Exited with code: 1 

我在做什麼錯?

回答

1

Accounts.ui.config僅在客戶端可用(請參閱文檔here),因此您需要將其用於Meteor.isClient。與此更換您的app.js應該工作:

if(Meteor.isClient) { 
    Accounts.ui.config({ passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL' }); 
} 

或者,你可以創建一個名爲「客戶端」和一個名爲「服務器」文件夾中的文件夾,將流星知道如何處理那些不使用isClient和isServer 。

有關詳細信息,請參閱文檔中的「structuring your app」或「我應該在哪裏放置文件?」。在unofficial faq

0

我得到這個錯誤,因爲我沒有添加帳戶基礎和帳戶用戶界面。我剛剛添加了帳戶 - [服務]軟件包。一旦我添加了它們,錯誤就消失了,一切都很好。