Search code examples
javascripthtmllaravelhref

How to use javascript value in href (Laravel)


Im trying to make simple website using QR Code. I use QR Code scanner from instascan from github. This line is to show scan result

<li v-for="scan in scans" :key="scan.date" :title="scan.content">@{{ scan.content }}</li>

How to use that result in href tag like <a href="/products/show/{{ scan.content }}">@{{ scan.content }}</a> The link should be http://example.com/products/show/qrscanresult

Thank you, sorry for my bad english.


Solution

  • You can bind the value like you have done with the other attributes in your question and just concatenate it to the initial part of the url:

    <a :href="'/products/show/' + scan.content">@{{ scan.content }}</a>