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 simple folding Panel with vue.js

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to achieve simple folding panel in vue.js". In daily operation, I believe many people have doubts about how to achieve simple folding panel in vue.js. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to achieve simple folding panel in vue.js". Next, please follow the editor to study!

The details are as follows

The code is as follows:

Master file: app.vue

Vue logo

{{it.name}} import Collpase from'. / components/Collpase.vue' Import CollpaseItem from'. / components/CollpaseItem.vue'export default {name: 'App', data () {return {chapterList: [{name:' title one', list: [{name:'is so'} {name: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {name: 'aha'}, {name: 'Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale; text-align: center; color: # 2c3e50; margin-top: 60px;}

Subcomponents:

Export default {name: 'Collapse', props: {accordion: {type: [Boolean, String], default: false}}, provide () {return {collapse: this}}, created () {this.childrens = []} Methods: {onChange () {let activeItem = [] this.childrens.forEach ((vm) = > {if (vm.isOpen) {activeItem.push (vm.nameSync)}}) this.$emit ('change', activeItem)}} .collapse {width: Display: flex; flex: 1; flex-direction: column;}

Subcomponents:

{{title}}

Export default {name: 'UniCollapseItem', props: {title: {/ / list title type: String, default:'}, name: {/ / unique identifier type: [Number, String], default: 0}, disabled: {/ / whether type: Boolean, default: false} is disabled, showAnimation: {/ / whether to display animation type: Boolean Default: false}, open: {/ / whether to expand type: Boolean, default: false}, thumb: {/ / thumbnail type: String, default:''}}, data () {return {isOpen: false}}, watch: {open (val) {this.isOpen = val}}, inject: ['collapse'] Created () {this.isOpen = this.open this.nameSync = this.name? This.name: this.collapse.childrens.length this.collapse.childrens.push (this) if (String (this.collapse.accordion) = = 'true') {if (this.isOpen) {let lastEl = this.collapse.childrens [this.collapse.childrens.length-2] if (lastEl) {this.collapse.childrens [this.collapse.childrens.length-2] .isOpen = false} Methods: {onClick () {if (this.disabled) {return} if (String (this.collapse.accordion) = 'true') {this.collapse.childrens.forEach (vm = > {if (vm = this) {return} vm.isOpen = false})} this.isOpen =! this.isOpen this.collapse.onChange & & this.collapse.onChange () This.$forceUpdate ()}}. Collapse-cell {flex-direction: column Border-color: # f0f0f0; border-bottom-width: 1px.collapse-cell--open {background-color: # fff;}. Collapse-disabled {cursor: not-allowed! important;} .collapse-cell--hide {height: 48px;} .active-animation {transition-property: transform; transition-duration: 0.3s; transition-timing-function: ease;}. Collapse-cell__title {border-bottom: 1px solid # f0f0f0; padding: 12px 20px Position: relative; display: flex; width: 100%; box-sizing: border-box; height: 44px; line-height: 44px; flex-direction: row; justify-content: space-between; align-items: center; cursor: pointer;}. Collapse-cell__title-img {margin-right: 10px;} .title-arrow {width: 22px; height: 14px;} .active {transform: rotate (180deg) }. Collapse-cell__title-text {flex: 1; font-size: 16px; margin-right: 16px; white-space: nowrap; color: # 333333; font-weight: bold; lines: 1; overflow: hidden; text-overflow: ellipsis;}. Collapse-cell__content {overflow-x: hidden;}. Collapse-cell__wrapper {display: flex; flex-direction: column;}. Collapse-cell__content--hide {height: 0px Line-height: 0px;} at this point, the study on "how to achieve a simple folding panel with vue.js" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report