【问题标题】:Is there a way to reference MetaInfo in layouts for Gridsome?有没有办法在 Gridsome 的布局中引用 MetaInfo?
【发布时间】:2019-09-14 01:55:11
【问题描述】:

使用 Gridsome,我想在布局组件中引用任何给定页面的 MetaInfo,如下所示:

 <h1 class="page-title">
   {{ metaInfo.title }}
 </h1>

在页面中,我确实有这样定义的元信息(并且确实正确填充了头部)

export default {
  metaInfo: {
    title: 'About'
  }
}

【问题讨论】:

    标签: vue.js gridsome


    【解决方案1】:

    您必须将 metaInfo 对象更改为函数并返回标题对象。

    试试这个:

    <h1 class="page-title">
      {{ $metaInfo.title }}
    </h1>
    

    并在您的导出默认值中使用:

    metaInfo() {
      return {
        title: 'About'
      };
    }
    

    【讨论】:

      猜你喜欢
      • 2020-11-18
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 2020-11-30
      • 2015-03-23
      • 2015-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多