相关疑难解决方法(0)

流星中的全局变量

我有

var Schemas = {};

Meteor.isClient && Template.registerHelper("Schemas", Schemas);

Schemas.Person = new SimpleSchema({
  fullName: {
    type: String,
    index: 1,
    optional: true,
  },
  email: {
    type: String,
    optional: true
  },
  address: {
    type: String,
    optional: true
  },
  isActive: {
    type: Boolean,
  },
  age: {
    type: Number,
    optional: true
  }
});
Run Code Online (Sandbox Code Playgroud)

在一个文件和

var Collections = {};

Meteor.isClient && Template.registerHelper("Collections", Collections);

Persons = Collections.Persons = new Mongo.Collection("Persons");
Persons.attachSchema(Schemas.Person);
Run Code Online (Sandbox Code Playgroud)

在另一个文件中.

我收到了错误ReferenceError: Schemas is not defined.很明显,我必须Schemas在我的collections.js文件中定义而不是将它们分开.但Meteor如何在单独的文件中使用代码?我可以访问一些对象和变量,而其他对象和变量是无法访问的.

javascript scope node.js meteor

28
推荐指数
2
解决办法
3万
查看次数

如何在Meteor注销时删除会话变量?

我为用户设置了会话变量,用于跟踪和服务器的小更改,当用户注销并且新用户登录而不关闭浏览器时,会话变量仍处于活动状态.

示例Session.set("变量",变量)Session.get("variable")

我想我正在寻找的是如何在用户注销时强制页面重新加载.

session meteor

1
推荐指数
1
解决办法
3620
查看次数

标签 统计

meteor ×2

javascript ×1

node.js ×1

scope ×1

session ×1