Skip to content

Instantly share code, notes, and snippets.

@myesn
Created August 2, 2022 07:09
Show Gist options
  • Save myesn/faeb733d2bc184e8e724794c9f15bd35 to your computer and use it in GitHub Desktop.
Save myesn/faeb733d2bc184e8e724794c9f15bd35 to your computer and use it in GitHub Desktop.
<script setup>
import { ref, watchEffect } from 'vue'
const number = ref(0);
const unwatch = watchEffect((onCleanup) => {
const id = setInterval(() => {
number.value++;
}, 1000);
onCleanup(() => clearInterval(id));
})
</script>
<template>
<h1>{{ number }}</h1>
<input v-model="number">
<input type="button" @click="unwatch" value="unwatch" />
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment