【问题标题】:Meteor 1.3 collection reference errorMeteor 1.3 采集参考错误
【发布时间】:2016-06-07 12:27:04
【问题描述】:

流星 1.3: 我的项目架构是:

  • .meteor
  • 两者
    • articles.js
    • tags.js ...
  • 客户端
    • 模板
      • templates.html
      • templates.js
  • 服务器
    • main.js

我想将我的集合用于客户端和服务器中的一些检查,因此我使用:

import { CollectionName } from "path/to/Collection"

在客户端和服务器端

在我的收藏文件中:

export const CollectionName = new Mongo.Collection("collection");

我已经尝试使用 global.Collection 名称,在集合名称之前没有任何单词,就像在 Meteor 1.3 之前一样 -> 仍然得到:

Exception from sub articles id 2irSGEkWinCGvB33z ReferenceError: Articles is not defined

如果我只使用import './../both/collections/collectionName';,我会得到 CollectionName 未定义;

【问题讨论】:

  • 您的收藏文件在哪里?
  • 在两个文件夹中,还尝试将其移动到 lib 中的一个 collections.js 文件不起作用

标签: javascript meteor collections


【解决方案1】:

如果您想使用import,您需要将您的代码放在imports 目录下。请参阅指南的application structure 部分。特别是,请阅读 file structure 部分以获取示例布局。

【讨论】:

    猜你喜欢
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多