因业务需要,要做一个从右下角弹出的消息提醒,需要自定义元素和样式,其代码如下:
const h = this.$createElement
this.instance = this.$notify({
title: '来电提醒',
message: h('div', null, [
h('p', null,
[
h('img', {
attrs: {src: 'https://lcfile.sishuxuefu.com/cc2a754da594590a604f.png'},
style: 'vertical-align: center;width: 15px;height: 15px;border-color: #fff;dispaly: inline-block;margin-left:75px;margin-top: 15px;'
}),
h('span', customerNum, {
style: 'font-size: 16px;margin-left: 10px;dispaly: inline-block;'
})
]),
h('button', {
style: 'border-radius: 30px;margin-left: 50px;color: #fff;display: inline-block;width: 65px;height: 25px;background: #409EFF;border: none;font-size: 14px;margin-top: 20px;',
on: {
click: this.answer
}
}, '接听'),
h('button', {
style: 'border-radius: 30px;color: #fff;display: inline-block;width: 65px;height: 25px;background: #FA495F;margin-left: 30px;border: none;font-size: 14px;margin-top: 20px;',
on: {
click: this.hangup
}
}, '挂断')
]),
position: 'bottom-right',
duration: 0
})
h为创建一个元素,将其添加到notify中。可以自定义样式和属性,绑定事件