javascript - How to get text value of a clicked item in vue.js? - Stack Overflow

Here is the code: <li v-for="u in usersList"><strong><a class="username&q

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
}, 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742398715a4436473.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信