MattB
3 months ago
748
3
Vue

How do I pass 2 arguments to a getter in vuex?

Posted 3 months ago by MattB

So, not sure if this is the correct way of going about this but I am trying to create a getter which returns a gradient based off of 2 colors passed to it via a function. So far I have:

Function being called

  <v-card-text
                          style="height: 120px"
                          :style="{
                              'background-image': backgroundImage(
                                  card.color1,
                                  card.color2,
                              ),
                          }"
                          flat
                                ></v-card-text>

computed:

backgroundImage() {
            return this.backgroundImage(color1, color2)
        },

getter:

getters: {
        backgroundImage: () => (color1, color2) =>{
            let bgImage =
                'linear-gradient(to top right, ' + color1 + ',' + color2 + ')';
            return bgImage;
        }
        
    }

But when I run it now, I get this error

Error in render: "RangeError: Maximum call stack size exceeded"

Not sure what I did wrong or if this is the correct way to handle this sort of function in Vuex?

Please sign in or create an account to participate in this conversation.