应该在哪里设置 Meteor 默认值?

Where should Meteor defaults be set?

我想使用 Session.setDefault 为我的 Meteor 应用程序设置一些默认值。

我曾认为,根据首先加载顶级 lib 文件夹的 Meteor 文件的 load order,此代码的最佳位置是 lib/defaults.js 文件。但是,当我 运行 我的代码时,我得到一个 Session is not defined 错误

放置此代码的最佳位置在哪里才能在服务器和客户端上运行?

在 Meteor 中,Sessiononly available on the client. Therefore, you should set your defaults in your client folder, usually in a Meteor.startup() 钩子。

如果您需要为客户端和服务器端设置一些通用默认值,您可以在服务器端设置值,并在需要时使用 method calls (non-reactive) or use a Collection and subscribe to it 从客户端检索它们! (反应)