个人技术分享

在vue3中跳转函数有很多种方法,目前作者在用的有以下几种:


1、

<router-link to="{ name: 'OrderForGoods' }">我的订单</router-link>

2、

function my_team() {
  router.push({
    name: "My_Team",
  });
}

3、

const home = () => {
  router.push({
    name: "Home",
  });
};

4、

// 封装路由跳转函数  
function navigateTo(routeName) {  
  router.push({ name: routeName });  
}  

// 定义各个路由跳转函数  
const PromotionalInformation = () => navigateTo('PromotionalInformation'); 
const order = () => navigateTo('OrderForGoods');  
const canceled = () => navigateTo('Canceled');  

第4种比较方便,比较简洁,目前作者所知道到就这几种方法,有其他方便或者高级的方法请给作者指出来。