国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

彩票計劃網(wǎng)站開發(fā)哪里有競價推廣托管

彩票計劃網(wǎng)站開發(fā),哪里有競價推廣托管,商城網(wǎng)站建設(shè)價格費(fèi)用,建設(shè)直銷團(tuán)隊網(wǎng)站目錄 路由 Vue-Router1、Vue-Router 介紹2、路由配置3、嵌套路由3.1、簡介3.2、實現(xiàn)步驟3.3、?注意事項 4、?router-view標(biāo)簽詳解 ?🍃作者介紹:雙非本科大三網(wǎng)絡(luò)工程專業(yè)在讀,阿里云專家博主,專注于Java領(lǐng)域?qū)W習(xí),擅…

目錄

  • 路由 Vue-Router
  • 1、Vue-Router 介紹
  • 2、路由配置
  • 3、嵌套路由
    • 3.1、簡介
    • 3.2、實現(xiàn)步驟
    • 3.3、?注意事項
  • 4、?router-view標(biāo)簽詳解

?🍃作者介紹:雙非本科大三網(wǎng)絡(luò)工程專業(yè)在讀,阿里云專家博主,專注于Java領(lǐng)域?qū)W習(xí),擅長web應(yīng)用開發(fā)、數(shù)據(jù)結(jié)構(gòu)和算法,初步涉獵Python人工智能開發(fā)和前端開發(fā)。
🦅主頁:@逐夢蒼穹
📕所屬專欄:前端(專欄的其他文章,詳見文末?)
🍔您的一鍵三連,是我創(chuàng)作的最大動力🌹

路由 Vue-Router

1、Vue-Router 介紹

vue 屬于單頁面應(yīng)用,所謂路由,就是根據(jù)瀏覽器路徑不同,用不同的視圖組件替換這個頁面內(nèi)容。
不同的訪問路徑,對應(yīng)不同的頁面展示。

在vue應(yīng)用中使用路由功能,需要安裝Vue-Router:
image.png
image.png
image.png
注:創(chuàng)建完帶有路由功能的前端項目后,在工程中會生成一個路由文件,如下所示:
image.png
關(guān)于路由的配置,主要就是在這個路由文件中完成的。
為了能夠使用路由功能,在前端項目的入口文件main.js中,創(chuàng)建Vue實例時需要指定路由對象:
image.png

2、路由配置

首先了解一下路由組成:

  • VueRouter:路由器,根據(jù)路由請求在路由視圖中動態(tài)渲染對應(yīng)的視圖組件
  • <router-link>:路由鏈接組件,瀏覽器會解析成
  • <router-view>:路由視圖組件,用來展示與路由路徑匹配的視圖組件

具體配置方式:
1、在路由文件/router/index.js中配置路由路徑和視圖的對應(yīng)關(guān)系:

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'Vue.use(VueRouter)//維護(hù)路由表,某個路由路徑對應(yīng)哪個視圖組件
const routes = [{path: '/',name: 'home',component: HomeView},{path: '/about',name: 'about',component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')},{path: '/404',component: () => import('../views/404View.vue')},{path: '*',redirect: '/404'}
]const router = new VueRouter({routes
})export default router

2、在視圖組件中配置 router-link標(biāo)簽,用于生成超鏈接

<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link> |
<router-link to="/test">Test</router-link> |

image.png
3、在視圖組件匯總配置router-view標(biāo)簽
image.png
要實現(xiàn)路由跳轉(zhuǎn),可以通過標(biāo)簽式和編程式兩種:

  • 標(biāo)簽式:About
  • 編程式:this.$router.push(‘/about’)

問題思考: 如果用戶訪問的路由地址不存在,該如何處理?
可以通過配置一個404視圖組件,當(dāng)訪問的路由地址不存在時,則重定向到此視圖組件,具體配置如下:

{path: '/404',component: () => import('../views/404View.vue')
},
{path: '*',redirect: '/404' //重定向
}

3、嵌套路由

3.1、簡介

嵌套路由:組件內(nèi)要切換內(nèi)容,就需要用到嵌套路由(子路由),效果如下:
在App.vue視圖組件中有標(biāo)簽,其他視圖組件可以展示在此
ContainerView.vue組件可以展示在App.vue視圖組件的位置

ContainerView.vue組件進(jìn)行了區(qū)域劃分(分為上、左、右),在右邊編寫了標(biāo)簽,點擊左側(cè)菜單時,可以將對應(yīng)的子視圖組件展示在此

3.2、實現(xiàn)步驟

第一步:安裝并導(dǎo)入 elementui,實現(xiàn)頁面布局(Container 布局容器)—ContainerView.vue:

<template><el-container><el-header>Header</el-header><el-container><el-aside width="200px"></el-aside><el-main></el-main></el-container></el-container>
</template><script>
export default {}
</script><style>
.el-header, .el-footer {background-color: #B3C0D1;color: #333;text-align: center;line-height: 60px;}.el-aside {background-color: #D3DCE6;color: #333;text-align: center;line-height: 200px;}.el-main {background-color: #E9EEF3;color: #333;text-align: center;line-height: 160px;}body > .el-container {margin-bottom: 40px;}.el-container:nth-child(5) .el-aside,.el-container:nth-child(6) .el-aside {line-height: 260px;}.el-container:nth-child(7) .el-aside {line-height: 320px;}
</style>

第二步:提供子視圖組件,用于效果展示 ->P1View.vue、P2View.vue、P3View.vue:

<template><div>這是P1 View</div>
</template><script>
export default {}
</script><style>
.el-header, .el-footer {background-color: #B3C0D1;color: #333;text-align: center;line-height: 60px;}.el-aside {background-color: #D3DCE6;color: #333;text-align: center;line-height: 200px;}.el-main {background-color: #E9EEF3;color: #333;text-align: center;line-height: 160px;}body > .el-container {margin-bottom: 40px;}.el-container:nth-child(5) .el-aside,.el-container:nth-child(6) .el-aside {line-height: 260px;}.el-container:nth-child(7) .el-aside {line-height: 320px;}
</style>

第三步:在 src/router/index.js 中配置路由映射規(guī)則(嵌套路由配置)

{path: '/c',component: () => import('../views/container/ContainerView.vue'),//嵌套路由(子路由),對應(yīng)的組件會展示在當(dāng)前組件內(nèi)部children: [//通過children屬性指定子路由相關(guān)信息(path、component){path: '/c/p1',component: () => import('../views/container/P1View.vue')},{path: '/c/p2',component: () => import('../views/container/P2View.vue')},{path: '/c/p3',component: () => import('../views/container/P3View.vue')}]
}

第四步:在ContainerView.vue 布局容器視圖中添加,實現(xiàn)子視圖組件展示

<el-main><router-view/>
</el-main>

第五步:在ContainerView.vue 布局容器視圖中添加,實現(xiàn)路由請求

<el-aside width="200px"><router-link to="/c/p1">P1</router-link><br><router-link to="/c/p2">P2</router-link><br><router-link to="/c/p3">P3</router-link><br>
</el-aside>

注意:子路由變化,切換的是【ContainerView 組件】中 部分的內(nèi)容
問題思考:
1.對于前面的案例,如果用戶訪問的路由是 /c,會有什么效果呢?

如何實現(xiàn)在訪問 /c 時,默認(rèn)就展示某個子視圖組件呢?
配置重定向,當(dāng)訪問/c時,直接重定向到/c/p1即可,如下配置:
image.png

3.3、?注意事項

  1. 子路由的路徑不需要以 / 開頭。因為以 / 開頭的路徑將會被視為根路徑。
  2. 子路由的完整路徑是由其所有的祖先路由的路徑和自己的路徑拼接而成的。例如,/user/:id/profile 路徑是由 /user/:id 和 profile 拼接而成的。
  3. 子路由的寫法,要么"/父/子",要么"子":
    image.png
    更多關(guān)于嵌套路由的信息,你可以查閱Vue Router官方文檔。

4、?router-view標(biāo)簽詳解

<router-view/> 是 Vue Router 的一個核心組件,它是一個功能性的組件,用于渲染匹配的路由組件。
當(dāng)你的應(yīng)用訪問一個路由路徑時,Vue Router 會查找與該路徑匹配的路由配置,然后將該路由配置中的組件渲染到 <router-view/> 所在的位置。
例如,假設(shè)你有以下的路由配置:

const routes = [{ path: '/home', component: Home },{ path: '/about', component: About }
]

當(dāng)你訪問 /home 路徑時,Home 組件會被渲染到 <router-view/> 所在的位置;當(dāng)你訪問 /about 路徑時,About 組件會被渲染到 <router-view/> 所在的位置。
此外,<router-view/> 還可以嵌套使用,以支持顯示嵌套路由。在嵌套路由的配置中,子路由的組件將會被渲染到父路由組件內(nèi)部的 <router-view/> 中。
例如,假設(shè)你有以下的嵌套路由配置:

const routes = [{ path: '/user', component: User,children: [{path: 'profile',component: UserProfile},{path: 'posts',component: UserPosts}]}
]

當(dāng)你訪問 /user/profile 路徑時,User 組件會被渲染到最外層的 <\router-view/> 中,而 UserProfile 組件會被渲染到 User 組件內(nèi)部的 <router-view/> 中。

?
????????????????????前端的其他文章:
📕 1-創(chuàng)建vue工程
📕 2-vue的基本使用

?

http://aloenet.com.cn/news/38895.html

相關(guān)文章:

  • 淘寶客優(yōu)惠卷網(wǎng)站怎么做的百度官方網(wǎng)首頁
  • 個性網(wǎng)站功能百度推廣服務(wù)費(fèi)3000元
  • 錦溪網(wǎng)站建設(shè)百度云搜索引擎官方入口
  • seo建設(shè)網(wǎng)站百度seo招聘
  • 中山做網(wǎng)絡(luò)推廣的公司廣告優(yōu)化師工資一般多少
  • 做推廣優(yōu)化的網(wǎng)站有哪些寧波最好的推廣平臺
  • wordpress站點臨時關(guān)閉seo自然優(yōu)化排名技巧
  • 做商城網(wǎng)站哪里買寧波seo推廣推薦公司
  • icp網(wǎng)站負(fù)責(zé)人網(wǎng)絡(luò)推廣平臺都有哪些
  • 甘南州住房和城鄉(xiāng)建設(shè)局網(wǎng)站百度一下就知道百度首頁
  • 寧波企業(yè)網(wǎng)站搭建特點百度一下百度一下你知道
  • 網(wǎng)站制作多久能完成廣州優(yōu)化疫情防控措施
  • 深圳做網(wǎng)站的網(wǎng)絡(luò)公2022年傳銷最新消息
  • 做曖曖視頻網(wǎng)站下載東營網(wǎng)站建設(shè)制作
  • 什么網(wǎng)站做微信公眾賬號seo專員工作容易學(xué)嗎
  • 做像素畫的網(wǎng)站岳陽seo公司
  • 局網(wǎng)站建設(shè)情況匯報官網(wǎng)制作公司
  • windows7怎么做網(wǎng)站服務(wù)器新聞式軟文
  • 中企動力做的網(wǎng)站被百度屏蔽關(guān)鍵詞查詢工具有哪些
  • 銀行網(wǎng)站維護(hù)是做哪些seo排名教程
  • 網(wǎng)站如何做長尾詞排名宣傳推廣文案
  • 寧波網(wǎng)站建設(shè)明細(xì)報價1小時快速搭建網(wǎng)站
  • 網(wǎng)站圖怎么做才能小而清晰百度灰色關(guān)鍵詞技術(shù)
  • 成都企業(yè)網(wǎng)站維護(hù)專業(yè)外貿(mào)網(wǎng)絡(luò)推廣
  • 做網(wǎng)站 一級 二級2023年10月爆發(fā)新冠
  • 產(chǎn)品開發(fā)流程及每個流程內(nèi)容網(wǎng)站優(yōu)化網(wǎng)站優(yōu)化
  • 官方網(wǎng)站建設(shè)條件博客網(wǎng)站注冊
  • 搜索網(wǎng)站怎么做東營優(yōu)化路網(wǎng)
  • 安徽平臺網(wǎng)站建設(shè)找哪家國產(chǎn)最好的a級suv88814
  • 哈爾濱企業(yè)展示型網(wǎng)站建設(shè)搜索引擎優(yōu)化期末考試答案