1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view class="tn-collapse-class tn-collapse">
- <slot></slot>
- </view>
- </template>
- <script>
- export default {
- name: 'tn-collapse',
- props: {
-
- accordion: {
- type: Boolean,
- default: true
- },
-
- headStyle: {
- type: Object,
- default() {
- return {}
- }
- },
-
- bodyStyle: {
- type: Object,
- default() {
- return {}
- }
- },
-
- itemStyle: {
- type: Object,
- default() {
- return {}
- }
- },
-
- arrow: {
- type: Boolean,
- default: true
- },
-
- arrowColor: {
- type: String,
- default: '#AAAAAA'
- },
-
- hoverClass: {
- type: String,
- default: 'tn-hover'
- }
- },
- computed: {
- parentData() {
- return [this.headStyle, this.bodyStyle, this.itemStyle, this.arrow, this.arrowColor, this.hoverClass]
- }
- },
- data() {
- return {
-
- }
- },
- watch: {
- parentData() {
-
- if (this.childrens.length > 0) {
- this.init()
- }
- }
- },
- created() {
- this.childrens = []
- },
- methods: {
-
- init() {
- this.childrens.forEach((child, index) => {
- child.init()
- })
- },
-
- onChange() {
- let activeItem = []
- this.childrens.forEach((child, index) => {
- if (child.isShow) {
- activeItem.push(child.nameSync)
- }
- })
-
- if (this.accordion) activeItem = activeItem.join(',')
- this.$emit('change', activeItem)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|