naive-ui/demo/documentation/components/dropdown/zhCN/trigger.md
2020-02-04 22:07:55 +08:00

1.2 KiB

触发

<n-dropdown @select="handleSelect" trigger="hover" :options="options">
  <n-button>悬浮!</n-button>
</n-dropdown>

<n-dropdown @select="handleSelect" trigger="click" :focusable="false" :options="options">
  <n-button>点击!</n-button>
</n-dropdown>

<n-dropdown @select="handleSelect" trigger="manual" :show="showDropdown" :options="options">
  <n-button @click="handleClick">噢!我要自己手动!</n-button>
</n-dropdown>
export default {
  data () {
    return {
      options: [
        {
          label: '滨海湾金沙,新加坡',
          key: 'marina bay sands'
        },
        {
          label: '布朗酒店,伦敦',
          key: 'brown\'s hotel, london'
        },
        {
          label: '亚特兰蒂斯巴哈马,拿骚',
          key: 'atlantis nahamas, nassau'
        },
        {
          label: '比佛利山庄酒店,洛杉矶',
          key: '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;
}