以下是代码:
<li v-for="u in usersList">
<strong><a class="username" @click="openChatbox">${ u } </a></strong>
</li>
和处理方法:
openChatbox: function() {
target = event.target || event.srcElement;
this.isOpen = !this.isOpen;
this.recepient = target.innerHTML
},
问题是,当recepient
值为<strong>noob</strong>
时,此方法会将u
设置为noob
。我怎样才能获得noob
?
答案 0 :(得分:4)
您可以在方法中传递用户如下:
<li v-for="u in usersList">
<strong><a class="username" @click="openChatbox(u)">${ u } </a></strong>
</li>
并在以下方法中使用它:
openChatbox: function(user) {
//use user here
},