当前位置:主页 > 网页前端 > vue >

vue根据进入的路由进行原路返回的方法

时间:2021-04-09 09:00:20 | 栏目:vue | 点击:

情景:

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
 },
 })
 }
}

您可能感兴趣的文章:

相关文章