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.

Vue.jsのstoreの中のgettersからgettersを呼び出すには

Posted at

わかれば簡単なのですが、知らないとググってもなかなか見つけられなかったので、メモしておきます。

gettersの関数が呼び出されるとき、第1引数は state なのですが、第2引数に getters が渡されるようです。

なので、以下のように書けます。

getters: {
    foo(state) {
    	return state._foo;
    },
    bar(state, getters) {
  	    return 2 * getters.foo;
    },
}
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?