Home > Net >  v-if contains advanced statement
v-if contains advanced statement

Time:02-10

I have images with contains alt different names, and I want to make a filter with these names, what I want to do is for example if the "current_variant" is red I want to show images that have '#red' and images that do not have '#' together '#yellow' in that case.

1.image [image_alt#red]
2.image [image_alt#yellow]
3.image [image_alt]
4.image [image_alt]

current_variant.alt = image_alt#red

with this line, I manage to call images with alt names but the problem is on the second statement removes the first because it includes '#'

v-if="current_variant.alt == '{{ media.alt }}' !== current_variant.alt.indexOf('#') > -1"

CodePudding user response:

Your description is not clear but let me guess...

You probably have a list of images let's say a gallery and you are trying to do something similar to this: https://codesandbox.io/s/agitated-poincare-j7enl?file=/src/App.vue

It would be very helpful though if you added more info on what you are trying to do.

  • Related