use vuex with composition API

master
Andreas Zweili 2021-09-06 13:05:02 +02:00
parent 7c0c233b4b
commit b7cb5d789d
2 changed files with 17 additions and 6 deletions

View File

@ -3,11 +3,16 @@
</template>
<script>
import { useStore } from 'vuex';
export default {
setup() {
function inc() {}
const store = useStore();
function inc() {
store.dispatch('increment');
}
return { inc };
},
}
};
</script>
</script>

View File

@ -3,11 +3,17 @@
</template>
<script>
import { computed } from 'vue';
import { useStore } from 'vuex';
export default {
setup() {
const counter = 0;
const store = useStore();
const counter = computed(function() {
return store.getters.counter;
});
return { counter };
},
}
};
</script>
</script>