今有需求查看通知需打开消息页面,出现连续打开只显示第一条消息,created、activated 等都不会再次触发,智能通过监听路由参数更新数据
附代码
1、跳转路由
//打开商机通知
openNotice(notice){
let data = {id:notice.id,messageStatus:1}
updateSysMessage(data).then(res=>{
})
let notices = this.businessOpportunity
this.businessOpportunity = []
for (let noticeMsg of notices){
if (noticeMsg.id != notice.id){
this.businessOpportunity.push(noticeMsg)
}
}
this.show()
this.$router.push({ name: 'baseDetail', query: { id: notice.messageSourceId } })
},
2、路由监听
watch:{
$route(to,form){
this.baseId = to.query.id
this.getBase()
}
},