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

 
(같은 사용자의 중간 판 10개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;Vue.js mounted
;Vue.js mounted


<syntaxhighlight lang='html' line highlight='13-15'>
<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: function () { ... }
</syntaxhighlight>
<syntaxhighlight lang='javascript' highlight='17-22'>
<div id="app">
<div id="app">
   <ul>
   <ul>
     <li v-for='todo in todos'>
     <li v-for='todo in todos'>
       <span v-if='todo.completed'>✔️</span>
       <span v-if='todo.completed'>✔️</span> {{ todo.title }}
      {{ todo.title }}
     </li>
     </li>
   </ul>
   </ul>
21번째 줄: 49번째 줄:
   },
   },
   mounted() {
   mounted() {
     axios.get('https://jsonplaceholder.typicode.com/todos')
     axios.get('//jsonplaceholder.typicode.com/todos')
     .then((response) => {
     .then((response) => {
       this.todos = response.data;
       this.todos = response.data;
29번째 줄: 57번째 줄:
</script>
</script>
</syntaxhighlight>
</syntaxhighlight>
<jsfiddle>81zcdev2</jsfiddle>
<jsfiddle height='200'>81zcdev2</jsfiddle>


<syntaxhighlight lang='javascript'>
<syntaxhighlight lang='javascript'>
41번째 줄: 69번째 줄:


==같이 보기==
==같이 보기==
* [[Vue.js data]]
* [[Vue.js methods]]
* [[Vue.js created()]]
* [[Vue.js created()]]
* [[Vue.js onMounted]]
* [[Vue.js beforeMount()]]
* [[Vue.js beforeMount()]]
* [[Vue.js 수명주기 ]]
* [[Vue.js 수명주기]]
* [[jQuery .ready()]]


==참고==
==참고==

2023년 10월 24일 (화) 16:31 기준 최신판

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 }}