1、element-ui Notification重疊問題,參考這個 https://blog.csdn.net/weixin_44423832/article/details/90239121
原因如下:
$notify在計算通知的間距時,會取當前元素的高度 item.$el.offsetHeight ,但是因為vue的異步更新隊列有緩沖機制,第一次方法調用時,並沒有更新dom,導致取到的高度為0,所有第二個通知只是上移了默認的offset 16px,並沒有加上第一個通知的高度
是不重疊了,但是問題來了:
他們的都是手動關閉,而我的需要自動關閉,幾秒鍾的關閉正常,
但是5分鍾后的自動關閉不對了,,,個別高達10分鍾也不消失
嘗試了多種方法
1、setTimeout延遲執行,不成
2、async await ,不成
3、寫成promise也不行
最終也是瞎蒙,,可以了,哭死。。。。。。。。。。 $nextTick寫在promise回調里,,不過好像也不是很穩定
that.notifyPromise = that.notifyPromise.then(()=>{ that.$nextTick(()=>{ that.$notify({ // message: "<div @click="+that.goAlarmList()+"style='color: #fff;'>"+that.getDeviceType(el.typeId) + "設備告警,請查看!</div>", title: "請查看!", type: 'warning', offset: 60, position: 'bottom-right', dangerouslyUseHTMLString: true, duration: 300000, onClick: function(){ that.$router.push({ path: '/alarmJudgement', query: { id: el.id // device:n } }) } }) }) })