其他分享
首页 > 其他分享> > Vue 在$notify中添加样式和事件

Vue 在$notify中添加样式和事件

作者:互联网

将dangerouslyUseHTMLString设置为true,就可以添加html代码,从而设置样式。

this.$notify({
dangerouslyUseHTMLString: true,
message:'Add in <span style="font-style: normal;color: #17e1e1;text-decoration: underline;cursor: pointer;" id="messageTrack">My Tracked</span>',
type: 'success',
});


其中设置id是为了添加鼠标点击事件

mounted () {
//监听鼠标点击事件
document.addEventListener('mouseup', (e) => {
let _track = document.getElementById('messageTrack');
if (_track) {
if (_track.contains(e.target)) {
this.toMy();//事件
}
}
});
}

methods: {
toMy () {
//逻辑
}
}

标签:toMy,Vue,样式,track,添加,notify,document,true
来源: https://www.cnblogs.com/dream-007/p/16419316.html