mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-17 10:20:34 +03:00
chore: add docs site
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# How to use component props or data
|
||||
|
||||
Easy. Instead of defining `metaInfo` as an object, define it as a function and access `this` as usual:
|
||||
|
||||
**Post.vue:**
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<h1>{{{ title }}}</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'post',
|
||||
props: ['title'],
|
||||
data () {
|
||||
return {
|
||||
description: 'A blog post about some stuff'
|
||||
}
|
||||
},
|
||||
metaInfo () {
|
||||
return {
|
||||
title: this.title,
|
||||
meta: [
|
||||
{ vmid: 'description', name: 'description', content: this.description }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
**PostContainer.vue:**
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<post :title="title"></post>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Post from './Post.vue'
|
||||
|
||||
export default {
|
||||
name: 'post-container',
|
||||
components: { Post },
|
||||
data () {
|
||||
return {
|
||||
title: 'Example blog post'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
Reference in New Issue
Block a user