如何在 href (Laravel) 中使用 javascript 值
How to use javascript value in href (Laravel)
我正在尝试使用二维码制作简单的网站。我使用来自 github 的 instascan 的二维码扫描仪。这一行是为了显示扫描结果
<li v-for="scan in scans" :key="scan.date" :title="scan.content">@{{ scan.content }}</li>
如何在像 <a href="/products/show/{{ scan.content }}">@{{ scan.content }}</a>
这样的 href 标签中使用该结果
link 应该是 http://example.com/products/show/qrscanresult
谢谢,抱歉我的英语不好。
假设{{scan.script}}是变化的js变量。
<a href="/products/show/<script>{{ scan.content }}</script>">@{{ scan.content }}</a>
或
<script>var link = '<a href="/products/show/"+{{ scan.content }}></a>Text Goes here</a>'</script>
您可以像对问题中的其他属性所做的那样绑定该值,并将其连接到 url:
的初始部分
<a :href="'/products/show/' + scan.content">@{{ scan.content }}</a>
我正在尝试使用二维码制作简单的网站。我使用来自 github 的 instascan 的二维码扫描仪。这一行是为了显示扫描结果
<li v-for="scan in scans" :key="scan.date" :title="scan.content">@{{ scan.content }}</li>
如何在像 <a href="/products/show/{{ scan.content }}">@{{ scan.content }}</a>
这样的 href 标签中使用该结果
link 应该是 http://example.com/products/show/qrscanresult
谢谢,抱歉我的英语不好。
假设{{scan.script}}是变化的js变量。
<a href="/products/show/<script>{{ scan.content }}</script>">@{{ scan.content }}</a>
或
<script>var link = '<a href="/products/show/"+{{ scan.content }}></a>Text Goes here</a>'</script>
您可以像对问题中的其他属性所做的那样绑定该值,并将其连接到 url:
的初始部分<a :href="'/products/show/' + scan.content">@{{ scan.content }}</a>