naive-ui/demo/documentation/components/confirm/zhCN/useComponent.md

582 B

使用组件

有的时候你可能想把它用作一个组件

<n-confirm
  title="确认"
  content="你确定" 
  :closable="false"
  negative-text="不确认"
  positive-text="确认"
  @positive-click="handlePositiveClick"
  @negative-click="handleNegativeClick"
/>
export default {
  methods: {
    handleNegativeClick () {
      this.$NMessage.warning('取消')
      this.isActive = false
    },
    handlePositiveClick () {
      this.$NMessage.success('确认')
      this.isActive = false
    }
  }
}
.n-button {
  margin: 0 12px 8px 0;
}