使用Gridsome

时间:2019-09-02 04:08:57

标签: vue.js vue-router gridsome

我正在尝试为Gridsome为我自动生成的路线指定meta object,如下所示:

meta: {
      auth: true
    }

但是Gridsome中没有正常的route / index.js文件-在index.js中只有这样暴露的路由器对象:

export default function (Vue, { router, head, isClient }) 
{}

如何进入路由器并将元添加到要修改的特定路由中?

1 个答案:

答案 0 :(得分:0)

您可以通过组件脚本标签中的route获取this对象

<script>
export default {
  created () {
    this.$route.meta = {requiresAuth: true}    
  }
}
</script>