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

【Vue-Router】命名視圖

這篇具有很好參考價(jià)值的文章主要介紹了【Vue-Router】命名視圖。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

命名視圖

同時(shí) (同級(jí)) 展示多個(gè)視圖,而不是嵌套展示,例如創(chuàng)建一個(gè)布局,有 sidebar (側(cè)導(dǎo)航) 和 main (主內(nèi)容) 兩個(gè)視圖,這個(gè)時(shí)候命名視圖就派上用場了。

可以在界面中擁有多個(gè)單獨(dú)命名的視圖,而不是只有一個(gè)單獨(dú)的出口。

如果 router-view 沒有設(shè)置名字,那么默認(rèn)為 default。一個(gè)視圖使用一個(gè)組件渲染,因此對于同個(gè)路由,多個(gè)視圖就需要多個(gè)組件。
【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript
First.vue

<template>
  <h1>First Seciton</h1>
</template>

Second.vue

<template>
  <h1>Second Seciton</h1>
</template>

Third.vue

<template>
  <h1>Third Seciton</h1>
</template>

index.ts

import { createRouter, createWebHistory } from 'vue-router'
import First from '../components/First.vue'
import Second from '../components/Second.vue'
import Third from '../components/Third.vue'

export const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      components: {
        default: First,
        a: Second,
        b: Third,
      },
    },
    {
      path: '/other',
      components: {
        default: Third,
        a: Second,
        b: First,
      },
    },
  ],
})

App.vue

<template>
  <h1>Named Views</h1>
  <ul>
    <li>
      <router-link to="/">First page</router-link>
    </li>
    <li>
      <router-link to="/other">Second page</router-link>
    </li>
  </ul>
  <router-view></router-view>
  <router-view name="a"></router-view>
  <router-view name="b"></router-view>
</template>

<script setup lang="ts">

</script>

<style scoped></style>

【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript
【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript

嵌套命名視圖

【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript
First.vue

<template>
  <h1>First Seciton</h1>
</template>

Second.vue,Third.vue代碼同理

UserSettings.vue

<template>
  <h1>UserSettings</h1>
  <router-link to="/settings/children1">children1</router-link>
  <br />
  <router-link to="/settings/children2">children2</router-link>
  <br>
  <button @click="toBackPage">返回</button>
  <hr>
  <router-view></router-view>
  <router-view name="a"></router-view>
  <router-view name="b"></router-view>
</template> 

<script setup lang="ts">
import { useRouter } from 'vue-router';
const router = useRouter();
const toBackPage = () => {
  router.go(-1);
}
</script>

<style scoped></style>

index.ts

import { createRouter, createWebHistory } from 'vue-router'
import First from '../components/First.vue'
import Second from '../components/Second.vue'
import Third from '../components/Third.vue'
import UserSettings from '../components/UserSettings.vue'

export const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/settings',
      component: UserSettings,
      children: [
        {
          path: 'children1',
          components: {
            default: First,
            a: Second,
            b: Third,
          },
        },
        {
          path: 'children2',
          components: {
            default: Third,
            a: Second,
            b: First,
          },
        },
      ]
    },

  ],
})

App.vue

<template>
  <h1>Nested Named Views</h1>
  <hr>
  <router-view></router-view>
  <hr>
</template>

<script setup lang="ts">

</script>

<style scoped></style>

【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript
【Vue-Router】命名視圖,Vue-Router,vue.js,javascript,ecmascript文章來源地址http://www.zghlxwxcb.cn/news/detail-649107.html

到了這里,關(guān)于【Vue-Router】命名視圖的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • 路由,vue-router的基本用法,vue-router的常見用法$route.params、$router.push、$router.replace、$router.go

    路由,vue-router的基本用法,vue-router的常見用法$route.params、$router.push、$router.replace、$router.go

    路由(英文: router)就是 對應(yīng)關(guān)系 。 SPA指的是一個(gè)web網(wǎng)站只有唯一的一個(gè)HTML頁面, 所有組件的展示與切換 都在這唯一的一個(gè)頁面內(nèi)完成。此時(shí), 不同組件之間的切換 需要通過 前端路由 來實(shí)現(xiàn)。 *結(jié)論:*在SPA項(xiàng)目中, 不同功能之間的切換 ,要 依賴于前端路由 來完成! 通俗

    2024年01月16日
    瀏覽(27)
  • 路由vue-router

    路由vue-router

    路由(英文:router)就是 對應(yīng)關(guān)系 SPA 指的是一個(gè) web 網(wǎng)站只有 唯一的一個(gè) HTML 頁面 ,所有組件的展示與切換都在這唯一的一個(gè)頁面內(nèi)完成。 此時(shí),不同組件之間的切換需要通過前端路由來實(shí)現(xiàn)。 結(jié)論: 在 SPA 項(xiàng)目中,不同功能之間的切換 ,要依賴于 前端路由 來完成!

    2024年02月07日
    瀏覽(25)
  • 【Vue-Router】別名

    【Vue-Router】別名

    后臺(tái)返回來的路徑名不合理,但多個(gè)項(xiàng)目在使用中了,不方便改時(shí)可以使用別名。可以有多個(gè)或一個(gè)。 First.vue Second.vue , Third.vue 代碼同理 UserSettings.vue index.ts App.vue

    2024年02月12日
    瀏覽(22)
  • vue-router筆記

    目的:為了實(shí)現(xiàn)SPA(單頁面應(yīng)用) vue-router是一個(gè)插件庫 安裝: 路由的配置路徑:/src/router/index.js 路由組件的目錄:/src/pages/ 一般組件的目錄:/src/components/ 使用: main.js: App.vue: About.vue: 不可見的路由組件在哪?? ? ? ? 被銷毀了 嵌套路由的案例: 路由傳參: query: 傳參

    2024年02月12日
    瀏覽(29)
  • Uncaught SyntaxError: The requested module ‘/node_modules/.vite/deps/vue-router.js?v=9eef87ba‘

    錯(cuò)誤代碼 錯(cuò)誤提示 瀏覽器中路由無法顯示,提示錯(cuò)誤 問題描述 解決方法

    2024年02月05日
    瀏覽(107)
  • Vue3配置路由(vue-router)

    Vue3配置路由(vue-router)

    緊接上篇文章,vue3的配置與vue2是有所差別的,本文就講述了如何配置,如果本文對你有所幫助請三連支持博主。 下面案例可供參考 使用npm命令進(jìn)行安裝 : npm install vue-router@4 完成后我們打開項(xiàng)目根目錄下的 package.json 文件: 如下即為成功 這里創(chuàng)建 view目錄,然后在view目錄

    2023年04月12日
    瀏覽(27)
  • VUE-CLI/VUE-ROUTER

    VUE-CLI/VUE-ROUTER

    個(gè)人簡介 ??個(gè)人主頁:是Lay的主頁 ??學(xué)習(xí)方向:JAVA后端開發(fā)? ??種一棵樹最好的時(shí)間是十年前,其次是現(xiàn)在! ?往期文章:【Java基礎(chǔ)】面向?qū)ο筮M(jìn)階(二) ??喜歡的話麻煩點(diǎn)點(diǎn)關(guān)注喔,你們的支持是我的最大動(dòng)力。 目錄 ? 前言: 1. 安裝 1.1 npm安裝 1.2 vue-cli安裝 2. 初始化項(xiàng)

    2024年01月16日
    瀏覽(72)
  • vue-router路由守衛(wèi)

    在我們使用vue-router的時(shí)候,路由守衛(wèi)就像監(jiān)聽器、攔截器一樣,幫我們做一些鑒權(quán)等操作,vue中的路由守衛(wèi)分為全局路由守衛(wèi)、獨(dú)享路由守衛(wèi)、組件內(nèi)的路由守衛(wèi) 全局路由守衛(wèi) :?beforeEach、 afterEach 組件獨(dú)享路由守衛(wèi) :beforeEnter、 beforeLeave 組件內(nèi)路由守衛(wèi) :beforeRouteEnter、

    2024年02月11日
    瀏覽(17)
  • 【Vue-Router】路由入門

    【Vue-Router】路由入門

    路由(Routing)是指確定網(wǎng)站或應(yīng)用程序中特定頁面的方式。在Web開發(fā)中,路由用于根據(jù)URL的不同部分來確定應(yīng)用程序中應(yīng)該顯示哪個(gè)內(nèi)容。 構(gòu)建前端項(xiàng)目 安裝依賴和路由 3. router 使用 login.vue reg.vue index.ts App.vue main.ts router-view 補(bǔ)充: router-view 是Vue Router提供的一個(gè)組件,用于

    2024年02月13日
    瀏覽(28)
  • Vue-Router基本使用

    Vue-Router基本使用

    1 安裝: vue2項(xiàng)目要安裝vue-router@3版本 npm i vue-router@3 2 src下創(chuàng)建router目錄,router文件夾下創(chuàng)建index.js 在vue.config.js中?配置src路徑別名 ?3 在main.js中引入 4 在app.vue中配置 ?5 即可看到內(nèi)容 ? ?

    2024年02月15日
    瀏覽(24)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包