<template>
<div class="counter">
<span>{{ count }}</span>
<button @click="increment">+</button>
<button @click="decrement">-</button>
</div>
</template>
<script>
export default {
name: 'Counter',
props: {
initialCount: {
type: Number,
default: 0
}
},
data() {
return {
count: this.initialCount
}
},
methods: {
increment() {
this.count++
},
decrement() {
this.count--
}
}
}
</script>
<style scoped>
.counter {
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
}
</style>