Home >Web Front-end >JS Tutorial >vue changes the state of the currently selected item

vue changes the state of the currently selected item

php中世界最好的语言
php中世界最好的语言Original
2018-04-12 17:20:152429browse

This time I will bring you the status of vue to change the currently selected item. What are the notes for vue to change the status of the currently selected item? The following is a practical case. Get up and take a look.

In vue, it is no longer possible to directly operate dom like jq. If you want to point to the currently selected item, you can no longer use jq's idea. The method is as follows:

When pointing to a state, only the pointed state is hidden, and other items remain unchanged. If element-ui is used in the project, the operation will be simpler. Set it like this:

v-if="(row.id == currentId&&row.auditState==0)?checkState:!checkState" @mouseover="statehidden(row.id)"

js:

statehidden(id){
   this.currentId=id; 
  },

The idea of ​​this method is: When the mouse points to an item, the id of the item is obtained and stored in a variable, and it is judged that row.id== currentId, just control the display and hiding of this button, because the id of the current item can only be obtained when the mouse points to an item, so you can use row.id==currentId to judge, so that you can Easily control the changes of the current item

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Detailed explanation of the use of vue better-scroll's scrolling plug-in

How to use the mint-ui time plug-in Get the selection value

The above is the detailed content of vue changes the state of the currently selected item. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn