<template>
  <div>
    <ul>
      <li v-for="(item, index) in list" :key="index">
        <p @click="changeContent(index)">{{ item.title }}</p>
        <div class="box" v-show="item.showContent">11111</div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "Collapse",
  props: {
    list: {
      type: Array,
      required: true,
      default() {
        return [];
      }
    }
  },
  methods: {
    changeContent(index) {
      //通过index拿到当前值
      this.list[index].showContent = !this.list[index].showContent;
    }
  }
};
</script>

<style></style>
