How does vue.js get the text content in the table td element?

                <td id="er" ref="td">
                    {{item.username}}
                    <a style="float:right;color:DarkGray;font-size:13px" v-show="showdelete"></a>
                </td>
                
                

traverses the data in the background, and the user name in td is the obtained user name. I want to realize the hidden reality delete button by judging whether the user name stored in cookie is equal to the user name in td. To achieve the ability to delete dynamic.
then how to get the user name in this td.

clipboard.png

Nov.14,2021

simple, the showdelete in v-show is changed into a method, and the item.username is passed in


2 schemes:

  • combine document.getElementById ('er'). InnerText; ) to do it;
  • user name of the index corresponding to the data cache

<td id="er" ref='td'>
    {{item.username}}
    <a style="float:right;color:DarkGray;font-size:13px" v-show="showdelete" @click="del()"></a>
</td>

del(){
    console.log(this.$ref.td)
}

in this way, the dom node td can be selected

Menu