Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Created July 11, 2022 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyWay/bc89098d51db1fa632cb45ed8c54d685 to your computer and use it in GitHub Desktop.
Save JeffreyWay/bc89098d51db1fa632cb45ed8c54d685 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step by Step, Episode 24 - Direct Mutation Concerns
import { reactive } from "vue";
export let counter = reactive({
// state
count: 0,
// action
increment() {
if (this.count >= 10) {
return;
}
this.count++;
}
});
<script setup>
import {counter} from "@/stores/counterStore";
</script>
<template>
<div>
<h1>{{ counter.count }}</h1>
<button @click="counter.increment()">Increment</button>
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment