如何将Vue数据中的值传递给href? [英] How to pass a value from Vue data to href?
本文介绍了如何将Vue数据中的值传递给href?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试做这样的事情:
<a bind-href="'/job/'r.id">{{ r.job_title }} </a>
我不知道如何将 r.id
的值添加到 href
属性的末尾,以便我可以进行 API 调用.有什么建议吗?
解决方案
您需要使用 v-bind:
或其别名 :
.例如,
或
I'm trying to do something like this:
<div v-for="r in rentals">
<a bind-href="'/job/'r.id"> {{ r.job_title }} </a>
</div>
I can't figure out how to add the value of r.id
to the end of the href
attribute so that I can make an API call. Any suggestions?
解决方案
You need to use v-bind:
or its alias :
. For example,
<a v-bind:href="'/job/'+ r.id">
or
<a :href="'/job/' + r.id">
这篇关于如何将Vue数据中的值传递给href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文