15.04 Add a Computed Getter & Setter

This commit is contained in:
Fredrick W Warren 2021-02-11 15:57:52 -08:00
parent fe08b091e7
commit ff3233fa49
2 changed files with 17 additions and 3 deletions

View File

@ -19,15 +19,23 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters, mapActions } from 'vuex'
export default { export default {
name: 'PageSettings', name: 'PageSettings',
computed: { computed: {
...mapGetters('settings', ['settings']), ...mapGetters('settings', ['settings']),
show12HourTimeFormat () { show12HourTimeFormat: {
return this.settings.show12HourTimeFormat get () {
return this.settings.show12HourTimeFormat
},
set (value) {
this.setShow12HourTimeFormat(value)
}
} }
},
methods: {
...mapActions('settings', ['setShow12HourTimeFormat'])
} }
} }
</script> </script>

View File

@ -5,9 +5,15 @@ const state = {
} }
const mutations = { const mutations = {
setShow12HourTimeFormat (state, value) {
state.settings.show12HourTimeFormat = value
}
} }
const actions = { const actions = {
setShow12HourTimeFormat ({ commit }, value) {
commit('setShow12HourTimeFormat', value)
}
} }
const getters = { const getters = {