Learn Vue with Me EP.7 - เรื่อง Template ref และ Watchers
VueJS
ฟรี
#VueJS
#vue.js
#Vue
Lifecycle and ref
- ref เริ่มต้นเป็นค่า
null
<p ref="pElementRef">hello</p>access
const pElementRef = ref(null)onMount
import { onMounted } from 'vue'
onMounted(() => { // component is now mounted.})Watchers
import { ref, watch } from 'vue'
const count = ref(0)
watch(count, (newCount) => { // yes, console.log() is a side effect console.log(`new count is: ${newCount}`)})