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

2번째 줄: 2번째 줄:
;Vue.js mounted
;Vue.js mounted


<syntaxhighlight lang='javascript'>
<script>
export default {
  data() {
    return {
      count: 0
    }
  },
  methods: {
    increment() {
      this.count++
    }
  },
  mounted() {
    console.log(`The initial count is ${this.count}.`)
  }
}
</script>
<template>
  <button @click="increment">Count is: {{ count }}</button>
</template>
</syntaxhighlight>
----
<syntaxhighlight lang='javascript'>
<syntaxhighlight lang='javascript'>
mounted() { ...  }
mounted() { ...  }

2023년 5월 4일 (목) 15:20 판

1 개요

Vue.js mounted


<script>
export default {
  data() {
    return {
      count: 0
    }
  },
  methods: {
    increment() {
      this.count++
    }
  },
  mounted() {
    console.log(`The initial count is ${this.count}.`)
  }
}
</script>

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

mounted() { ...  }
mounted: function () { ... }
<div id="app">
  <ul>
    <li v-for='todo in todos'>
      <span v-if='todo.completed'>✔️</span> {{ todo.title }}
    </li>
  </ul>
</div>

<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/axios"></script>
<script>
new Vue({
  el: '#app',
  data: {
    todos: []
  },
  mounted() {
    axios.get('//jsonplaceholder.typicode.com/todos')
    .then((response) => {
      this.todos = response.data;
    })
  }
});
</script>
mounted: function () {
  this.$nextTick(function () {
    // Code that will run only after the
    // entire view has been rendered
  })
}

2 같이 보기

3 참고

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