[Vuejs]-Call vue.js function in html to print value in p tag

3👍

Just remove a semicolon ; in your template.

Using JavaScript Expressions.

new Vue({
  el: "#app",
  data() {
    return {
      Threads: [1, 2, 3]
    }
  },
  methods: {
    getName(Thread) {
      return 1;
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <div v-for="Thread in Threads">
    <p>{{ getName(Thread) }}</p>
  </div>
</div>

Leave a comment