[Vuejs]-Why I can't get the value of counter at output? It is showing like "The button above has been clicked {{ counter }} times."

0๐Ÿ‘

โœ…

You have to return the data value.

<div id="example-1">
    <button v-on:click="counter += 1">Add 1</button>
    <p>The button above has been clicked {{ counter }} times.</p>
  </div>
  <script>
    var example1 = new Vue({
    el: '#example-1',
    data: data: function () {
    return { // need to return things
      counter: 0
    }
  },
  })
  </script>

Check this out here.

1๐Ÿ‘

Data Must Be a Function


data: () => ({
    counter: 0
})

Leave a comment