Skip to content

Instantly share code, notes, and snippets.

@ycmjason
Created February 26, 2020 16:26
Show Gist options
  • Save ycmjason/4a97281e1c3dc818af591953a5210aa1 to your computer and use it in GitHub Desktop.
Save ycmjason/4a97281e1c3dc818af591953a5210aa1 to your computer and use it in GitHub Desktop.
import { ref, computed, watch } from '@vue/runtime-core'
const counter = ref(0)
const squared = computed(() => counter.value ** 2)
setInterval(() => counter.value += 1, 1000)
watch(() => {
console.log(`counter: ${counter.value}`, `counter²: ${squared.value}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment