Interactive Counter Component

Easy5 minutes

Build a functional counter component using Vue.js that allows users to increment and decrement a value.

Component Requirements

  • Use Vue's data() function to manage a count value
  • Display the current count in a paragraph with id value
  • Include two buttons: one with id increment and another with id decrement
  • Properly increase and decrease the count when the corresponding buttons are clicked

Implementation Notes

  • Start with the count initialized to 0
  • Define increment and decrement methods to update the count
  • Your component should be the default export
  • This challenge uses Vue's Options API format

Example Code Structure

return {
  data() {
    return {
      // Your data here
    }
  },
  methods: {
    // Your methods here
  },
  template: `
    <div class="counter-app">
      <p id="value">0</p>
      <div class="button-group">
        <button id="increment">+</button>
        <button id="decrement">-</button>
      </div>
    </div>
  `
}
Component.vue
Loading...

Preview not started

Run tests or click the preview button to see your component in action