我正在尝试将从 v-for 获得的值附加到同一标记中的属性,但没有成功。这是我的代码:
<label
v-for="hashtag in hashtags"
v-bind:title=`You can filter with {hashtag}`
v-bind:data-value="hashtag"
></label>
基本上,值会转到 title
和 data-value
最佳答案
你的标题绑定(bind)应该在表达式前后有双引号,而且你似乎想要在标题中插入一个字符串,但我认为它不会起作用。
试试这个(你可以省略 v-bind cus :
它是它的简写)
<label v-for="hashtag in hashtags" :title="'You can filter with ' + hashtag" :data-value="hashtag">
{{ hashtag }}
</label>
关于vue.js - 如何将 v-for 值绑定(bind)到 Vue 中的 HTML 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46004437/