naive-ui/demo/documentation/components/message/enUS/manuallyClose.md
2019-12-08 20:59:25 +08:00

562 B

Manually Close

<n-button @click="openMessage">
  Open
</n-button>
<n-button @click="closeMessage">
  Close
</n-button>
export default {
  data() {
    return {
      message: null
    }
  },
  methods: {
    openMessage () {
      if (!this.message) {
        this.message = this.$NMessage.info('3 * 3 * 4 * 4 * ?', {
          duration: 0
        })
      }
    },
    closeMessage () {
      if (this.message) {
        this.message.close()
        this.message = null
      }
    }
  }
}
.n-button {
  margin: 0 12px 8px 0
}