【问题标题】:How to pass variable to top-level template?如何将变量传递给顶级模板?
【发布时间】:2012-08-22 04:35:50
【问题描述】:

我的意思是,如何将变量传递给顶层 html,而不是模板。谢谢

<head>
  <title>{{app_name}}</title>
</head>

【问题讨论】:

    标签: html templates meteor


    【解决方案1】:

    似乎没有一种将变量传递到 head 部分的明显方法。您不能像在正文中那样在其中使用模板。

    但是,如果您愿意,可以通过 JavaScript 设置标题。您可以像这样在客户端代码中执行此操作:

    document.title = "My Page Title";
    

    缺点是在 JavaScript 加载之前不会设置标题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-10
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 2011-05-08
      • 2015-08-24
      相关资源
      最近更新 更多