Created
July 23, 2021 13:03
-
-
Save letswritetw/d838c238a72ad4118570bc2c553f200a to your computer and use it in GitHub Desktop.
vue-composition-api
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
<template> | |
<div> | |
<input type="text" v-model="search"> | |
<input type="text" v-model="search2"> | |
</div> | |
</template> | |
<script> | |
import { ref, watch, watchEffect } from 'vue' | |
export default { | |
name: 'HelloWorld', | |
setup() { | |
const search = ref(''); | |
watch(search, (newValue, oldValue) => { | |
console.log('watch search', newValue, oldValue) | |
}) | |
const search2 = ref(''); | |
watch(search2, () => { | |
console.log('watch search2', search2.value) | |
}) | |
watchEffect(() => { | |
console.log('watchEffect', search.value, search2.value) | |
}) | |
return { | |
search, search2 | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment