admin管理员组

文章数量:1336203

Here is the code:

<li v-for="u in usersList">
    <strong><a class="username" @click="openChatbox">${ u } </a></strong>
</li>

and the handling method:

openChatbox: function() {
    target = event.target || event.srcElement;
     this.isOpen = !this.isOpen;
     this.recepient = target.innerHTML
}, 

The problem is that this method sets recepientlike <strong>noob</strong> when u value is noob. How can I get only noob?

Here is the code:

<li v-for="u in usersList">
    <strong><a class="username" @click="openChatbox">${ u } </a></strong>
</li>

and the handling method:

openChatbox: function() {
    target = event.target || event.srcElement;
     this.isOpen = !this.isOpen;
     this.recepient = target.innerHTML
}, 

The problem is that this method sets recepientlike <strong>noob</strong> when u value is noob. How can I get only noob?

Share Improve this question edited Mar 14, 2017 at 6:29 Karlom asked Mar 14, 2017 at 6:23 KarlomKarlom 14.9k29 gold badges78 silver badges118 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You can pass the user like following in the method:

<li v-for="u in usersList">
    <strong><a class="username" @click="openChatbox(u)">${ u } </a></strong>
</li>

and use it in method like this:

openChatbox: function(user) {
   //use user here
}, 

本文标签: javascriptHow to get text value of a clicked item in vuejsStack Overflow