Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Created March 11, 2017 17:59
Show Gist options
  • Save vinicius73/d9cd0f89c77e5cc3ca88ec49ae027884 to your computer and use it in GitHub Desktop.
Save vinicius73/d9cd0f89c77e5cc3ca88ec49ae027884 to your computer and use it in GitHub Desktop.
viue - dinamic title
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)
}
})
}
<script>
export default {
title: 'Previous Operations',
}
</script>
<template>
<div class="layout-padding">
~
</div>
</template>
export default {
setTitle (state, value) {
state.title = value
}
}
export default {
title: null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment