"Vue.js onMounted"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
;Vue.js onMounted
;Vue.js onMounted
<syntaxhighlight lang='html'>
<script setup>
import { ref, onMounted } from 'vue'
const el = ref()
onMounted(() => {
  el.value // <div>
})
</script>
<template>
  <div ref="el"></div>
</template>
</syntaxhighlight>


<syntaxhighlight lang='html'>
<syntaxhighlight lang='html'>
24번째 줄: 40번째 줄:
</template>
</template>
</syntaxhighlight>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2023년 10월 24일 (화) 14:32 판

1 개요

Vue.js onMounted
<script setup>
import { ref, onMounted } from 'vue'

const el = ref()

onMounted(() => {
  el.value // <div>
})
</script>

<template>
  <div ref="el"></div>
</template>
<script setup>
import { ref, onMounted } from 'vue'

// reactive state
const count = ref(0)

// functions that mutate state and trigger updates
function increment() {
  count.value++
}

// lifecycle hooks
onMounted(() => {
  console.log(`The initial count is ${count.value}.`)
})
</script>

<template>
  <button @click="increment">Count is: {{ count }}</button>
</template>

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}