在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ v-for 怎么實(shí)現(xiàn)怎么實(shí)現(xiàn)對(duì)某個(gè)指定元素的文本節(jié)點(diǎn)的獲取呢?

v-for 怎么實(shí)現(xiàn)怎么實(shí)現(xiàn)對(duì)某個(gè)指定元素的文本節(jié)點(diǎn)的獲取呢?

通過v-for生成列表,每行中的tr都有復(fù)制按鈕,點(diǎn)擊復(fù)制實(shí)現(xiàn)對(duì)tr中的某個(gè)td文本節(jié)點(diǎn)copy,現(xiàn)在是不知道怎么獲取到item.code文本節(jié)點(diǎn),這個(gè)具體代碼如下:

<tr v-for="(item,index) in userListLimit" :key="index">

            <td>{{item.inserted_at}}</td>
            <td ref="itemCode">{{item.code}}</td>
            <td>{{item.inviter}}</td>
            <td>{{item.invitee}}</td>
            <td>{{item.when_long}}</td>
            <td :title="item.note">{{item.note}}</td>
            <td>
                <a v-if= "item.invitee==''?true:false" @click="myCopy($event)">復(fù)制</a>
            </td>

</tr>
// 點(diǎn)擊復(fù)制到剪貼板

  myCopy(event) {
   // event.target.parentNode.previousSibling.select()
    document.execCommand('Copy')
  },
回答
編輯回答
裸橙

我大概會(huì)這樣子做

<td :class="'cls_'+item.code">....</td>
<td><a @click="myCopy(item.code)">復(fù)制</td>
myCopy(code){
//document.getElementByClassName('cls_'+code)
}

復(fù)制文本的話可參考:https://www.cnblogs.com/wisew...

2017年12月7日 15:32
編輯回答
卟乖

直接把code作為參數(shù),myCopy里面修改
myCopy($event),event有用到嗎,沒用的話myCopy(item.code),有用的話myCopy($event,item.code);

然后在tr上綁定ref,這樣通過vue的ref就能找到節(jié)點(diǎn)啦。
<tr v-for="(item,index) in userListLimit" :key="index" :ref='item.code'>

2018年9月9日 11:38