mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
1.3 KiB
1.3 KiB
Trigger
<n-dropdown @select="handleSelect" trigger="hover">
<template v-slot:activator>
<n-button>Hover! On the Green Light!</n-button>
</template>
<n-dropdown-item
v-for="hotel in hotels"
:key="hotel"
:name="hotel.toLowerCase()"
:label="hotel"
/>
</n-dropdown>
<n-dropdown @select="handleSelect" trigger="click" :focusable="false">
<template v-slot:activator>
<n-button>Click! On the Green Light</n-button>
</template>
<n-dropdown-item
v-for="hotel in hotels"
:key="hotel"
:name="hotel.toLowerCase()"
:label="hotel"
/>
</n-dropdown>
<n-dropdown @select="handleSelect" trigger="manual" v-model="showDropdown">
<template v-slot:activator>
<n-button @click="handleClick">Oh! Manually By Myself!</n-button>
</template>
<n-dropdown-item
v-for="hotel in hotels"
:key="hotel"
:name="hotel.toLowerCase()"
:label="hotel"
/>
</n-dropdown>
export default {
data () {
return {
hotels: [
'Marina Bay Sands, Singapore', 'Brown’s Hotel, London', 'Atlantis Bahamas, Nassau', 'The Beverly Hills Hotel, Los Angeles'
],
showDropdown: false
}
},
methods: {
handleSelect (name) {
this.$NMessage.info(name)
},
handleClick () {
this.showDropdown = !this.showDropdown
}
}
}
.n-button {
margin: 0 8px 12px 0;
}