国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

重復(fù)導(dǎo)航到當(dāng)前位置引起的。Vue Router 提供了一種機制,阻止重復(fù)導(dǎo)航到相同的路由路徑。

這篇具有很好參考價值的文章主要介紹了重復(fù)導(dǎo)航到當(dāng)前位置引起的。Vue Router 提供了一種機制,阻止重復(fù)導(dǎo)航到相同的路由路徑。。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

重復(fù)導(dǎo)航到當(dāng)前位置引起的。Vue Router 提供了一種機制,阻止重復(fù)導(dǎo)航到相同的路由路徑。,vue.js,elementui,javascript

代碼:?

  <!-- 側(cè)邊欄 -->
        <el-col :span="12" :style="{ 'width': '200px' }">
          <el-menu default-active="first" class="el-menu-vertical-demo" @select="handleMenuSelect">
            <el-menu-item index="first">
              <i class="el-icon-menu"></i>
              <span slot="title">首頁</span>
            </el-menu-item>
            <el-menu-item index="person">
              <i class="el-icon-menu"></i>
              <span slot="title">個人中心</span>
            </el-menu-item>
            <el-menu-item index="score">
              <i class="el-icon-document"></i>
              <span slot="title">個人成績</span>
            </el-menu-item>
            <el-menu-item index="personal">
              <i class="el-icon-document"></i>
              <span slot="title">成績管理</span>
            </el-menu-item>
          
            <el-menu-item index="manage">
              <i class="el-icon-setting"></i>
              <span slot="title">人員管理</span>
            </el-menu-item>
          </el-menu>
        </el-col>
<script>
export default {
  methods: {
    handleMenuSelect(index) {
      this.$router.push({ path: '/' + index });
    }
  }
};
</script>

路由:

const routes = [
	

	{
		path: '/home',//路由地址
		name: 'home',
		component: home,//相對應(yīng)的組件
		redirect: { name: "first" },
		children: [
			{
				path: '/first',
				name: 'first',
				component: first
			},
			{
				path: '/person',
				name: 'person',
				component: person
			},
			{
				path: '/personal',
				name: 'personal',
				component: personal
			},
			{
				path: '/score',
				name: 'score',
				component: score
			},
			{
				path: '/manage',
				name: 'manage',
				component: manage
			}
		]
	}

]

目錄?

?重復(fù)導(dǎo)航到當(dāng)前位置引起的。Vue Router 提供了一種機制,阻止重復(fù)導(dǎo)航到相同的路由路徑。,vue.js,elementui,javascript

解決方法:判斷目標(biāo)路徑是否與當(dāng)前路徑相同

通過 this.$route.path 獲取到當(dāng)前路由的路徑文章來源地址http://www.zghlxwxcb.cn/news/detail-826392.html

 handleMenuSelect(index) {
      const targetPath = '/' + index;
      
      // 判斷目標(biāo)路徑是否與當(dāng)前路徑相同
      //通過 this.$route.path 獲取到當(dāng)前路由的路徑
      if (this.$route.path === targetPath) {
        // 如果相同則不進行導(dǎo)航
        return;
      }
      
      // 否則進行導(dǎo)航
      this.$router.push({ path: targetPath });
    }

到了這里,關(guān)于重復(fù)導(dǎo)航到當(dāng)前位置引起的。Vue Router 提供了一種機制,阻止重復(fù)導(dǎo)航到相同的路由路徑。的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包