I have an item.channelId that I have like to use in href. It should achieve something like this:
<a :href="https://youtube.com/${item.channelId}">{{
item.channelTitle
}}</a>
How can I put item.channelId into href?
Try using
<a :href="'https://youtube.com/'+item.channelId">{{item.channelTitle}}</a>
In the above example the property value href is treated as the string sum of 'https://youtube.com/' and the value in the variable item.channelId
If you want to make use of template literals, try
<a :href="`https://youtube.com/${item.channelId}`">{{item.channelTitle}}</a>
In case of template literals, the variable values are written inside ${} syntax and the entire string will be enclosed inside backticks (` `)
It should be:"`https://youtube.com/${item.channelId}`" with backticks.
You can check here: Template Literals
I think you are trying to use Template Literals. You should surround your string with backticks for it to work and not just "".
Everything inside backticks will be considered a string aside from anything with ${variable-name} will be considered a variable.
:href="`https://youtube.com/${item.channelId}`"