Skip to content

Instantly share code, notes, and snippets.

@letswritetw
Created July 23, 2021 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letswritetw/d838c238a72ad4118570bc2c553f200a to your computer and use it in GitHub Desktop.
Save letswritetw/d838c238a72ad4118570bc2c553f200a to your computer and use it in GitHub Desktop.
vue-composition-api
<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