Created
March 11, 2017 17:59
-
-
Save vinicius73/d9cd0f89c77e5cc3ca88ec49ae027884 to your computer and use it in GitHub Desktop.
viue - dinamic title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Vue => { | |
Vue.mixin({ | |
created () { | |
const { title } = this.$options | |
if (title !== undefined) { | |
this.$title = title | |
} | |
} | |
}) | |
Object.defineProperty(Vue.prototype, '$title', { | |
get () { | |
return this.$store.state.title | |
}, | |
set () { | |
this.$store.dispatch('setTitle', ...arguments) | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
title: 'Previous Operations', | |
} | |
</script> | |
<template> | |
<div class="layout-padding"> | |
~ | |
</div> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
setTitle (state, value) { | |
state.title = value | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
title: null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment