[Vue] The difference between router.push and router.resolve page jump of Router

open method

router.push 只能当前窗口Open

router.resolve 结合 window.openCan新窗口打开

Parameter passing

router.push 支持query和params

router.resolve only supports query, if you need to make the address bar parameters invisible, you need to combine localStorage or a third-party plug-in to save

this.$router.push

// 地址栏里带参
this.$router.push({
    
    
  path: '这里是path',
  query: {
    
    
    a: 1,
  },
});

// 地址栏里不带参
this.$router.push({
    
    
  name: '这里是name',
  params: {
    
    
    a: 1,
  },
});

this.$router.resolve

// 地址栏里带参
let data = this.$router.resolve({
    
    
  path: "/channel_sms",// 或者 name: 'channel_sms',
  query: {
    
    
    a: 1,
  },
});
window.open(data.href, '_blank');

// 地址栏里不带参
let data = this.$router.resolve({
    
    
  name: 'channel_sms',
});
localStorage.setItem('a', 1);
// 然后跳转页接收 localStorage.getItem('a');

Guess you like

Origin blog.csdn.net/qq_39900031/article/details/130376114