Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the expansion and contraction function of list items in vue

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "vue how to achieve the list item expansion contraction function", the content is detailed, the steps are clear, the details are handled properly, I hope this "vue how to achieve list item expansion contraction function" article can help you solve your doubts, the following follows the editor's ideas slowly in-depth, together to learn new knowledge bar.

Expansion effect-look at the red box area

Shrink effect-look at the red box area

Next, let's look at the code logic.

# template: the functional codes that are not related to this article have been removed

{{index+1}} {{item.subName}}  

{{item.fileName}} 

# js: the functional codes that are not related to this article have been removed

Data () {return {courseSubList: [], / / course body list}} Methods: {showHide (index) {if (this.$ refs.child.style.display = = 'none') {this.$ refs.childhood [index] .style.display =' flex' this.$ refs.arrow [index] .style.transform = 'rotateX (0deg)'} else {this.$ refs.childhood [index] .style.display = 'none' this.$ refs.arrow.style.transform =' rotateX (180deg)'} DeletCourseSub (id) {/ / function code omitted}}

# Analysis process:

Add the ref= "arrow" attribute to the unfolded arrow respectively

Add ref= "child" to the outermost tag of the single item content area of the list, that is, the class= "audio-body" of this article.

Add a showHide (index) event to the arrow label area

Finally, the corresponding index uses the ref attribute of vue to change the corresponding list item to expand and collapse.

Read this, the "vue how to achieve the list of individual expansion contraction function" article has been introduced, want to master the knowledge of this article still need to practice and use to understand, if you want to know more related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report