[Vuejs]-How to get text using vue.js 2?

5👍

Why does your HTML look like that?

You should never need to do what you’re asking in a Vue application. With a MVVM application you’d have something like:

new Vue({
  data: {
    total: 10,
  },
})

Then a template like:

<span class="badge" id="total">{{ total }}</span>

That way, in your VM, when you set this.total = 12 the DOM will update automatically and this.total will always return your total.

Leave a comment