Created
January 5, 2022 08:47
-
-
Save yann-yinn/114db71e1afa1544a2c1d009467dc245 to your computer and use it in GitHub Desktop.
watch Versus watchEffect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
import { ref, watch, watchEffect } from "vue"; | |
const price = ref(10); | |
const quantity = ref(1); | |
watchEffect(() => { | |
console.log("watchEffect()", price.value, quantity.value); | |
}); | |
watch(price, () => { | |
console.log("watch()", price.value, quantity.value); | |
}); | |
</script> | |
<template> | |
<main> | |
<div>Prix: <input v-model="price" type="number" /></div> | |
<div>Quantité: <input v-model="quantity" type="number" /></div> | |
</main> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment