naive-ui/demo/documentation/components/notification/enUS/basic.md

66 lines
1.7 KiB
Markdown
Raw Normal View History

2019-10-16 23:28:36 +08:00
# Basic
```html
<n-button @click="notify1">
Wouldn't it be Nice
</n-button>
<n-button @click="notify2">
Satisfaction
</n-button>
```
```js
export default {
methods: {
notify1 () {
this.$nNotify({
title: `Wouldn't it be Nice`,
2019-10-25 17:53:41 +08:00
subtitle: 'From the Beach Boys',
content: `Wouldn't it be nice if we were olderxxxxxxxxxxxxxxxxxxxxxxxx
2019-10-16 23:28:36 +08:00
Then we wouldn't have to wait so long
And wouldn't it be nice to live together
In the kind of world where we belong`,
meta: '2019-5-27 15:11',
2019-10-25 17:53:41 +08:00
action: [{
name: 'Mark as read',
onClick: (notificationVueInstance) => {
notificationVueInstance.close()
}
}],
2019-10-16 23:28:36 +08:00
avator: null,
2019-10-25 17:53:41 +08:00
beforeClose: (next) => {
next()
},
afterClose: (notificationVueInstance) => {
2019-10-16 23:28:36 +08:00
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
},
})
},
notify2 () {
2019-10-25 17:53:41 +08:00
let markAsRead = false
2019-10-16 23:28:36 +08:00
this.$nNotify({
title: 'Satisfaction',
content: `I cant get no satisfaction
I cant get no satisfaction
Cause I try and I try and I try and I try
I cant get no, I cant get no`,
meta: '2019-5-27 15:11',
2019-10-25 17:53:41 +08:00
beforeClose: (next) => {
if (markAsRead) next()
},
action: [
{
name: 'Mark as read',
onClick: (notificationVueInstance) => {
const notification = notificationVueInstance.notification
this.$NMessage.success(notification.title)
markAsRead = true
notificationVueInstance.close()
}
}
],
avator: null
2019-10-16 23:28:36 +08:00
})
}
}
}
```