0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

props

親→子に値を渡す時にはpropを使います。

props: {
      data: Array
  },

アクセス方法
js内


this.data

html内

<test :data="testNumber"></test>

※「:」は「v-bind:」の省略形です。

computed

データが更新されない限りキャッシュの値を使用しつづける

computed: {
  dataNow: function () {
        return Date.now()
   }
},

呼び出し方

{{ dataNow }}

methods

データに即時性を求める場合に使用する

methods: {
    dataNow: function () {
      return Date.now()
    }
 }

呼び出し方

{{ dataNow() }}
<div id="#app">
  <button @click=“dataNow”>ボタン</button> 
</div>

mounted

vueのライフサイクルフック(初期化)のうちの1つで
DOMが作成された直後に呼び出される。

mounted() {
          this.data = “data” ——>変数を定義したり
          this.getHeight() ——>メソッドを呼び出したり
 },

参考

https://reffect.co.jp/vue/vue-js-created-mounted-diffrence
https://zenn.dev/naoki_oshiumi/articles/8c99581ca5bdd0
https://cly7796.net/blog/javascript/try-using-vue-js-computed/
https://codelikes.com/vue-props/

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?