我有一个Vue组件,并向其中传递了道具:
export default {
props: [
"notificationDate",
"notificationType",
"notificationMessage",
"downLoadLink",
"inProgress",
"downloadImage",
"count",
"name"
],
在我的模板中,我使用以下道具:
<div class="notification">
<span class="time">{{notificationDate}}</span>
<p><b>{{notificationType}}:</b> {{notificationMessage}}</p>
对于一个道具“计数”,我想在按钮的click事件中将其传递给方法。我尝试过:
<b-button type="is-danger" size="is-small"
icon-right="delete" @click="deleteNotification(count)")">
Remove
</b-button>
但是在我的方法中,计数是不确定的:
methods: {
deleteNotification(count) {
//count is undefined
}}
如何将我的道具传递给@click方法?谢谢
答案 0 :(得分:1)
您可以这样传递它:
<b-button type="is-danger" size="is-small"
icon-right="delete" @click="deleteNotification(count)")">
Remove
</b-button>