Reputation: 776
I want to use srcset in v-img component in vuetify. I am passing the path from a data attribute.My src attribute is working fine with same syntax but srcset does not works.
Here is the code:
<v-img
:src="image.original_path"
:srcset="image.mobile_path 480w"
class="image-masonry mini-cover">
</v-img>
If I use it in this way it throws error. How can i set srcset properly? Any helps would be appreciated.
Upvotes: 2
Views: 3774
Reputation: 31
You have a variable and a raw string in the srcset you need to combine them to form a string. For example:
:srcset="`${image.mobile_path} 480w`"
or
:srcset="image.mobile_path + ' 480w'"
So the final version would would look like:
<v-img
:src="image.original_path"
:srcset="`${image.mobile_path} 480w`"
class="image-masonry mini-cover">
</v-img>
More info: Template strings
Upvotes: 3