admin管理员组文章数量:1405603
Can anyone please show me how to do this, I have a image with alt than contains alt="#color_blue" or alt="#color_orange", I call this data with Liquid as {{ media.alt }}
that I want to do is if the 'current_variant.alt' == {{ media.alt }} return true and also if the 'current_variant.alt' contain '#' return too true as well.
<div v-if="current_variant.alt == '{{ media.alt }}' && current_variant.alt == '#'">
</div>
I don't know how to let current_variant.alt check if the {{ media.alt }} contains #
Can anyone please show me how to do this, I have a image with alt than contains alt="#color_blue" or alt="#color_orange", I call this data with Liquid as {{ media.alt }}
that I want to do is if the 'current_variant.alt' == {{ media.alt }} return true and also if the 'current_variant.alt' contain '#' return too true as well.
<div v-if="current_variant.alt == '{{ media.alt }}' && current_variant.alt == '#'">
</div>
I don't know how to let current_variant.alt check if the {{ media.alt }} contains #
Share Improve this question asked Nov 27, 2021 at 5:35 ElkaziElkazi 1771 silver badge9 bronze badges2 Answers
Reset to default 3You can use the string.includes
method to check if a string contains a particular character.
If you want to check if current_variant.alt
equals media.alt
:
current_variant.alt == '{{ media.alt }}'
If you want to check if current_variant.alt
contains '#'
:
current_variant.alt.includes('#')
If you want to check if media.alt
contains '#'
:
'{{ media.alt }}'.includes('#')
To check if current_variant.alt contain #, use Javascript "includes" => current_variant.alt.includes('#')
<div v-if="current_variant.alt == media.alt && current_variant.alt.includes('#')">
</div>
本文标签: javascriptHow to Vue vif equal or containsStack Overflow
版权声明:本文标题:javascript - How to Vue v-if equal or contains - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744272518a2598252.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论