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

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


<syntaxhighlight lang='html' line highlight='10-14'>
<script>
export default {
  data() {
    return {
      count: 0
    }
  },
  methods: {
    increment() {
      this.count++
    }
  },
  mounted() {
    console.log(`The initial count is ${this.count}.`)
  }
}
</script>
----
<syntaxhighlight lang='html' run>
<syntaxhighlight lang='html' run>
<div id="app">
<div id="app">

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

1 개요

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


----
<syntaxhighlight lang='html' run>
<div id="app">
  <span>{{ count }}</span>
  <button @click="increment">+</button>
</div>

<script src="//unpkg.com/vue/dist/vue.min.js"></script>
<script>
new Vue({
  el: '#app',
  data: {
    count: 0
  },
  methods: {
    increment() {
      this.count++
      console.log(this.count)
    }
  }
})
</script>

2 같이 보기

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