国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

vue3頁(yè)面跳轉(zhuǎn)的兩種方式

瀏覽:234日期:2022-06-09 17:03:58
目錄
  • 1、標(biāo)簽內(nèi) router-link跳轉(zhuǎn)
  • 2、編程式路由導(dǎo)航

vue3的頁(yè)面跳轉(zhuǎn)有兩種方式,第一種是標(biāo)簽內(nèi)跳轉(zhuǎn),第二種是編程式路由導(dǎo)航

1、
<router-link to="/testDemo">
 <button>點(diǎn)擊跳轉(zhuǎn)1</button>
</router-link>
2、router.push("/testDemo");

1、標(biāo)簽內(nèi) router-link跳轉(zhuǎn)

通常用于點(diǎn)擊 查看 按鈕,跳轉(zhuǎn)到其他頁(yè)面

// 1、不帶參數(shù)直接跳轉(zhuǎn)
<router-link to="/testDemo">
 <button>點(diǎn)擊跳轉(zhuǎn)1</button>
</router-link>
<router-link :to="{name:"testDemo"}"> 
<router-link :to="{path:"/testDemo"}"> //name,path都行, 建議用name 
// 2、帶參數(shù)跳轉(zhuǎn)
// (1)query參數(shù)
<router-link :to="{path:"testDemo",query:{id:001}}">
 <button>點(diǎn)擊跳轉(zhuǎn)2</button>
</router-link>
// 類似類似get,url后面會(huì)顯示參數(shù)
// 路由可不配置
// (2)params參數(shù)
<router-link :to="{name:"testDemo",params:{setid:002}}">
 <button>點(diǎn)擊跳轉(zhuǎn)3</button>
</router-link>
// 類似post
// 路由配置 path: "/home/:id" 或者 path: "/home:id"

2、編程式路由導(dǎo)航

import { useRouter } from "vue-router";
const router = useRouter();
//直接跳轉(zhuǎn)
const handleChange = () => {
  router.push("/testDemo");
};
 //帶參數(shù)跳轉(zhuǎn)
router.push({path:"/testDemo",query:{id:003}});
router.push({name:"testDemo",params:{id:004}});

到此這篇關(guān)于vue3頁(yè)面跳轉(zhuǎn)的文章就介紹到這了,更多相關(guān)vue3頁(yè)面跳轉(zhuǎn)內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 比如县| 芒康县| 商洛市| 石泉县| 江安县| 金乡县| 汝南县| 马公市| 天柱县| 四会市| 和静县| 高雄市| 大关县| 屯留县| 江达县| 监利县| 湘西| 赤城县| 黔西| 靖江市| 滦平县| 永川市| 新闻| 临沭县| 综艺| 景洪市| 合山市| 大冶市| 达拉特旗| 华安县| 池州市| 新晃| 习水县| 定日县| 即墨市| 朝阳区| 上栗县| 兴山县| 裕民县| 瑞金市| 青冈县|