LoginSignup
0
0

More than 3 years have passed since last update.

【Vue.js】インスタンス内のプロパティーにアクセスする

Posted at

先ほどの関数をつかってい同じインスタンス内にあるメッセージプロパティーを呼ぶには「this.」をつける必要がある。

<body>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></script>
<div id="app">
<p>{{sayYes()}}</p>
<!-- <button v-on:click="reverseMessage">メッセージ反転</button> -->
</div>
<script>
  new Vue({
    el: '#app',
      data: { message: "おはよう"},
      methods: {
         sayYes: function() {
            return this.message;
      }
  }
})
</script>
</body>

20210504-114320.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0