Skip to content

Commit

Permalink
Merge pull request #5 from Binaryify/patch-2
Browse files Browse the repository at this point in the history
add middleware chinese document
  • Loading branch information
mamboer authored Feb 13, 2017
2 parents b6d58f7 + cde065f commit 28be759
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion cn/api/pages-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,32 @@ description: Documentation is coming soon.

# middleware 属性

> 文档未完待续!
类型: String 或 Array
Items: String

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

例子:
`pages/secret.vue`
```vue
<template>
<h1>Secret page</h1>
</template>
<script>
export default {
middleware: 'authenticated'
}
</script>
```
`middleware/authenticated.js`
```javascript
export default function ({ store, redirect }) {
// If the user is not authenticated
if (!store.state.authenticated) {
return redirect('/login')
}
}
```

想了解更多关于使用中间件的信息,请移步 [中间件指引](https://nuxtjs.org/guide/routing#middleware)

0 comments on commit 28be759

Please sign in to comment.