【问题标题】:Meteor Template.[name] is not definedMeteor Template.[name] 未定义
【发布时间】:2017-07-28 00:14:50
【问题描述】:

我正在重组我的 Meteor/Blaze 应用程序以将相关项目保留在“模块”中。但是我遇到了第一个模板的问题。

我的文件结构是这样的:

/imports
  /modules
    index.js
    /admin
      index.js
      methods.js
      /client
        adminPage.html
        adminPage.js

index.js 文件加载正常。 adminPage.jsadminPage.html 一起被导入。但是当我创建Template.adminPage.onCreated(...) 时,我收到一条错误消息,我无法在未定义的情况下调用函数。

adminPage.js 文件中调用console.log(Template) 会返回: Section showing the admin page in console.log output.

但如果我运行console.log(Template.adminPage),我会得到undefined。我不确定接下来要寻找什么。

【问题讨论】:

    标签: meteor meteor-blaze


    【解决方案1】:

    我发现了问题。而不是正确的:

    import { Template } from 'meteor/templating';
    

    我用过

    import Template from 'meteor/templating'; 
    

    【讨论】:

      【解决方案2】:

      您可能在/imports/modules/admin/client/adminPage.js 中缺少导入语句。在此文件的顶部添加以下内容:

      import './adminPage.html';
      

      【讨论】:

      • 不,它在那里。
      猜你喜欢
      • 2012-12-05
      • 2017-10-24
      • 1970-01-01
      • 2022-11-21
      • 2022-09-23
      • 2022-11-25
      • 1970-01-01
      • 2015-11-06
      • 2016-07-21
      相关资源
      最近更新 更多