Created
July 11, 2022 18:21
-
-
Save JeffreyWay/bc89098d51db1fa632cb45ed8c54d685 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step by Step, Episode 24 - Direct Mutation Concerns
This file contains 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
import { reactive } from "vue"; | |
export let counter = reactive({ | |
// state | |
count: 0, | |
// action | |
increment() { | |
if (this.count >= 10) { | |
return; | |
} | |
this.count++; | |
} | |
}); |
This file contains 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 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