思路:activekey的值为默认展开的项,要想全部展开,就得把所有的key值都加到 activekey中
如下例子,activekey=['1'] 默认展开第一个
要想全部展开就需要使 activeKey = ['1','2','3']
另外注意:如果key是数字,需要a-collapse-panel中的:key="String(index + 1) 要string一下
<template>
<div>
<a-collapse v-model="activeKey">
<a-collapse-panel header="This is panel header 1" key="1">
<p>{{text}}</p>
</a-collapse-panel>
<a-collapse-panel header="This is panel header 2" key="2" :disabled='false'>
<p>{{text}}</p>
</a-collapse-panel>
<a-collapse-panel header="This is panel header 3" key="3" disabled>
<p>{{text}}</p>
</a-collapse-panel>
</a-collapse>
</div>
</template>
<script>
export default {
data () {
return {
text: `A dog is a type of domesticated animal.Known for its loyalty and faithfulness,it can be found as a welcome guest in many households across the world.`,
activeKey: ['1']
}
},
watch: {
activeKey(key){
console.log(key)
}
},
}
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)