mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-24 12:45:18 +08:00
43 lines
754 B
Markdown
43 lines
754 B
Markdown
|
# 点击标题
|
||
|
```html
|
||
|
<n-collapse
|
||
|
v-model="activeNames"
|
||
|
@item-header-click="handleItemHeaderClick"
|
||
|
>
|
||
|
<n-collapse-item name="1">
|
||
|
<template v-slot:header>
|
||
|
青铜
|
||
|
</template>
|
||
|
<div>可以</div>
|
||
|
</n-collapse-item>
|
||
|
<n-collapse-item name="2">
|
||
|
<template v-slot:header>
|
||
|
白银
|
||
|
</template>
|
||
|
<div>很好</div>
|
||
|
</n-collapse-item>
|
||
|
<n-collapse-item name="3">
|
||
|
<template v-slot:header>
|
||
|
黄金
|
||
|
</template>
|
||
|
<div>真棒</div>
|
||
|
</n-collapse-item>
|
||
|
</n-collapse>
|
||
|
```
|
||
|
```js
|
||
|
export default {
|
||
|
data () {
|
||
|
return {
|
||
|
activeNames: []
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
handleItemHeaderClick ({
|
||
|
name,
|
||
|
expanded
|
||
|
}) {
|
||
|
this.$NMessage.info(`Name: ${name}, Expanded: ${expanded}`)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|