(编辑:jimmy 日期: 2024/11/20 浏览:2)
情景:
a---------->c 点击返回,希望返回到a
b---------->c 点击返回,希望返回到b
解决方案:
a页面,加from字段
PubSub.subscribe('table-view', function(msg, args) { var rowData = args[0], rowIndex = args[1]; //跳转详情页 this.$router.push({ name: 'viewAdvertiseDetails', query: { id: this.$route.query.id, adsenseCampaignId: rowData.id, from: 'viewAdvertise', }, }) }.bind(this));
b页面,加from字段
PubSub.subscribe('table-view', function(msg, args) { var rowData = args[0], rowIndex = args[1]; this.$router.push({ name: 'viewAdvertiseDetails', query: { id: this.$route.query.id, adsenseCampaignId: rowData.id, from: 'setAdvertise', }, }) }.bind(this));
c页面:
back: function() { if(this.$route.query.from==='viewAdvertise'){ this.$router.push({ name: 'viewAdvertise', query: { id: this.$route.query.id }, }) }else if(this.$route.query.from==='setAdvertise'){ this.$router.push({ name: 'setAdvertise', query: { id: this.$route.query.id }, }) } }
以上这篇vue根据进入的路由进行原路返回的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。