如何将数据传递给 vue native 中的按钮?
How passing data to a button in vue native?
我尝试向每个按钮传递一个循环浏览的标题。我有硬价值,我无法得到我真正的价值。
我尝试通过这种方式将我的变量像这样传递给标题标签 title
<view v-for="(post, index) in posts" :key="index">
<button
:title="post.name"
color="#841584"
/>
</view>
因此在我的按钮中我有 "post.name" 而我想要我的循环的真实值。
如果您希望从 for 循环中绑定按钮名称
你可以像这样绑定它
<button :title="post.name"
color="#841584">{{post.name}}</button>
我尝试向每个按钮传递一个循环浏览的标题。我有硬价值,我无法得到我真正的价值。
我尝试通过这种方式将我的变量像这样传递给标题标签 title
<view v-for="(post, index) in posts" :key="index">
<button
:title="post.name"
color="#841584"
/>
</view>
因此在我的按钮中我有 "post.name" 而我想要我的循环的真实值。
如果您希望从 for 循环中绑定按钮名称 你可以像这样绑定它
<button :title="post.name"
color="#841584">{{post.name}}</button>