2019-12-14 02:05:31 +08:00
|
|
|
# 触发
|
2020-12-12 14:44:44 +08:00
|
|
|
|
2020-10-21 23:22:08 +08:00
|
|
|
下拉菜单不同的触发方式。
|
2020-12-12 14:44:44 +08:00
|
|
|
|
2019-12-14 02:05:31 +08:00
|
|
|
```html
|
2020-10-04 04:07:14 +08:00
|
|
|
<n-space>
|
|
|
|
<n-dropdown @select="handleSelect" trigger="hover" :options="options">
|
|
|
|
<n-button :keyboard="false">悬浮!</n-button>
|
|
|
|
</n-dropdown>
|
|
|
|
<n-dropdown @select="handleSelect" trigger="click" :options="options">
|
|
|
|
<n-button :keyboard="false">点击!</n-button>
|
|
|
|
</n-dropdown>
|
|
|
|
<n-dropdown @select="handleSelect" :show="showDropdown" :options="options">
|
2020-12-12 14:44:44 +08:00
|
|
|
<n-button :keyboard="false" @click="handleClick"
|
|
|
|
>噢!我要自己手动!</n-button
|
|
|
|
>
|
2020-10-04 04:07:14 +08:00
|
|
|
</n-dropdown>
|
|
|
|
</n-space>
|
2019-12-14 02:05:31 +08:00
|
|
|
```
|
2020-12-12 14:44:44 +08:00
|
|
|
|
2019-12-14 02:05:31 +08:00
|
|
|
```js
|
|
|
|
export default {
|
2020-10-04 04:07:14 +08:00
|
|
|
inject: ['message'],
|
2020-12-12 15:33:41 +08:00
|
|
|
data () {
|
2019-12-14 02:05:31 +08:00
|
|
|
return {
|
2020-02-04 22:07:55 +08:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
label: '滨海湾金沙,新加坡',
|
2020-10-04 04:07:14 +08:00
|
|
|
key: 'marina bay sands'
|
2020-02-04 22:07:55 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '布朗酒店,伦敦',
|
2020-12-12 14:44:44 +08:00
|
|
|
key: "brown's hotel, london"
|
2020-02-04 22:07:55 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '亚特兰蒂斯巴哈马,拿骚',
|
2020-10-04 04:07:14 +08:00
|
|
|
key: 'atlantis nahamas, nassau'
|
2020-02-04 22:07:55 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '比佛利山庄酒店,洛杉矶',
|
2020-10-04 04:07:14 +08:00
|
|
|
key: 'the beverly hills hotel, los angeles'
|
2020-02-04 22:07:55 +08:00
|
|
|
}
|
2019-12-14 02:05:31 +08:00
|
|
|
],
|
|
|
|
showDropdown: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2020-12-12 15:33:41 +08:00
|
|
|
handleSelect (name) {
|
2020-10-04 04:07:14 +08:00
|
|
|
this.message.info(name)
|
2019-12-14 02:05:31 +08:00
|
|
|
},
|
2020-12-12 15:33:41 +08:00
|
|
|
handleClick () {
|
2019-12-14 02:05:31 +08:00
|
|
|
this.showDropdown = !this.showDropdown
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|