vue api code example

Example 1: vue js implementation

<div id="app">
  {{ message }}
</div>

Example 2: vue composition api

<template>
  <button @click="increment">
    Count is: {{ state.count }}, double is: {{ state.double }}
  </button>
</template>

<script>
import { reactive, computed } from 'vue'

export default {
  setup() {
    const state = reactive({
      count: 0,
      double: computed(() => state.count * 2)
    })

    function increment() {
      state.count++
    }

    return {
      state,
      increment
    }
  }
}
</script>

Example 3: vue

var app3 = new Vue({
  el: '#app-3',
  data: {
    seen: true
  }
})

Tags: