Want to take a look at our new docs? Our new docs are now in beta. Have fun!

API: middleware 属性

middleware 属性

  • 类型: StringArray
    • 数组元素类型: String

在应用中的特定页面设置中间件

例子:

pages/secret.vue

<template>
  <h1>Secret page</h1>
</template>

<script>
  export default {
    middleware: 'authenticated'
  }
</script>

middleware/authenticated.js

export default function ({ store, redirect }) {
  // If the user is not authenticated
  if (!store.state.authenticated) {
    return redirect('/login')
  }
}

想了解更多关于使用中间件的信息,请移步 中间件指引

Contribution for this page is now closed. If you would like to contribute please check out our new docs are now in beta. Have fun!

Platinum Sponsors

StoryblokMoovweb Support Us