如何将stripe.js添加到ember-cli应用程序中?

时间:2014-07-10 14:17:51

标签: ember.js bower ember-cli bower-install broccolijs

首先我通过bower包含了stripe.js文件:

bower install --save stripe.js=https://js.stripe.com/v2/

创建了“vendor / stripe / index”(注意不是 index.js,而是索引)。然后我把它添加到我的西兰花文件中:

app.import('vendor/stripe/index')

这给我带来了这个错误:

You must pass a file to `app.import`. For directories specify them to the constructor under the `trees` option.Error: You must pass a file to `app.import`. For directories specify them to the constructor under the `trees` option.
  at EmberApp.import (/home/jim/Desktop/TaskVelocity/task-velocity/node_modules/ember-cli/lib/broccoli/ember-app.js:521:11)
  at Object.<anonymous> (/home/jim/Desktop/TaskVelocity/task-velocity/Brocfile.js:9:11)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)

我错过了什么才能让它发挥作用?

尝试了用户的建议,并收到了此错误:

Path or pattern "vendor/stripe/stripe.js" did not match any files Error: Path or pattern "vendor/stripe/stripe.js" did not match any files 
at Object.multiGlob   (/home/jim/Desktop/TaskVelocity/web/node_modules/ember-cli/node_modules/broccoli‌​-concat/node_modules/broccoli-kitchen-sink-helpers/index.js:221:13) – 

3 个答案:

答案 0 :(得分:4)

就个人而言,我手动创建了所有内容,因为/ v2/index.js确实搞砸了。我知道,这并不理想,但Stripe现在在我的应用程序中工作得非常好。

在我的Brocfile.js中:

   app.import('vendor/stripe/stripe.js');

在我的应用程序的文件结构中,此文件位于:

   [appname]/vendor/stripe/stripe.js

如果我记得,还有条纹npm包。我不知道它是如何更新的。

答案 1 :(得分:1)

这不是正式认可的AFAICT,因此可能随时中断,但您可以安装这样的脚本:

bower install --save stripe.js=https://js.stripe.com/v2/stripe.js

这将创建一个index.js文件,然后您就可以正常使用了。

答案 2 :(得分:0)