vue.js - 如何将值从 Vue 数据传递给 href?

标签 vue.js href

我正在尝试做这样的事情:

<div v-for="r in rentals">
  <a bind-href="'/job/'r.id"> {{ r.job_title }} </a>
</div>  

我不知道如何将 r.id 的值添加到 href 属性的末尾,以便我可以进行 API 调用。有什么建议吗?

最佳答案

您需要使用v-bind: 或其别名:。例如,

<a v-bind:href="'/job/'+ r.id">

<a :href="'/job/' + r.id">

关于vue.js - 如何将值从 Vue 数据传递给 href?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899532/

相关文章:

javascript - Vue2 : How to redirect to another page using routes

html - 影响图像显示方式的 href

html - 从超链接 div 中的链接中删除下划线

vue.js - vue-router:如何检查当前路线是路线还是其子路线之一?

vue.js - 在tinymce-vue组件中设置整个编辑器的高度

javascript - Vue.js - 如何使用三元运算符在 vue 中返回带有很棒字体图标的 html

Vue.js 问题 : Prop doesn't change image v-bind:src

javascript - 检测 anchor 导致事件 window.location

html - ahref - 隐藏选择颜色

php - href 内的按钮