el-collapse-item v-for
时间: 2023-12-14 15:09:30 浏览: 30
"item in items" :key="item.id" :title="item.title"
:name="'collapse-' + item.id">
{{ item.content }}
</el-collapse-item>
In the above code snippet, "el-collapse-item" is a component from the Element UI library used to create a collapsible item. The "v-for" directive is used to loop through an array called "items" and generate a separate "el-collapse-item" component for each item in the array.
The ":key" binding provides a unique identifier for each item in the list to help Vue keep track of which items have been added, removed, or modified.
The ":title" binding sets the title of the collapsible item to the "title" property of the current item in the loop.
The ":name" binding sets a unique name for each collapsible item by concatenating the string "collapse-" with the "id" property of the current item.
Finally, the content of the collapsible item is displayed using Vue's template syntax, with the "item.content" property being interpolated into the component's body.