We will now refactor the copyright component that we already have in the /components/ directory. Let's get started:
- Remove the data function from the <script> block in the /components/base-copyright.vue file:
// components/copyright.vue
export default {
data () {
return { copyright: '© Lau Tiam Kok' }
}
}
- Replace the preceding data function with the props property, as follows:
// components/copyright.vue
export default {
props: ['copyright']
}
- Add the copyright data in the <script> block to /layouts/default.vue instead:
// layouts/default.vue
data () {
return {
copyright: '© Lau Tiam Kok',
}
}
- Remove the existing <Copyright /> component in the <template> block:
// layouts/default.vue
<Copyright />
- Add a new <Copyright /> component with the copyright data bound to it:
// layouts/default.vue
<Copyright v-bind:copyright...