中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

本科畢設做網站多少錢百度如何快速收錄網站

本科畢設做網站多少錢,百度如何快速收錄網站,家用電腦做網站,html網站模板路由&#xff08;Vue Router&#xff09; 用Vue Vue Router創(chuàng)建單頁面應用非常簡單。當加入Vue Router時&#xff0c;需要將組件映射到路由上&#xff0c;讓Vue知道在哪里渲染它們。 路由基本例子 <!-- 引入Vue 和 router --><script src"https://unpkg.com/vu…

路由(Vue Router)

Vue + Vue Router創(chuàng)建單頁面應用非常簡單。當加入Vue Router時,需要將組件映射到路由上,讓Vue知道在哪里渲染它們。
路由基本例子

    <!-- 引入Vue 和 router --><script src="https://unpkg.com/vue@3"></script><script scr="https://unpkg.com/vue-router@4"></script><div id="app"><p><!-- router-link類似a標簽,最后訪問的結果會放到router-view中 --><router-link to="/">Go to Home</router-link><router-link to="/about">Go to About</router-link></p><!-- 路由出口,路由匹配到的組件渲染在 <router-view> --><router-view></router-view></div

路由的第一個Demo

    //1. 定義兩個模版const Home = {template:'<div>Home</div>'}const About = {template:'<div>About</div>'}//2. 自定義路由對象,也就是匹配模版所對應的路徑配置const routers = [{path:'/',component:Home},{path:'/about',component:About}]//3. 創(chuàng)建路由實例,并傳遞自定義的配置const router = VueRouter.createRouter({history:VoeRouter.createWebHashHistory(),routers:routers})//4. 創(chuàng)建Vue實例,并且使用路由const app = Vue.createApp({})//5.使用路由 , 任意組件中可以使用`this.$router`的形式訪問router實例app.use(router)app.mount('#app')

動態(tài)路由

路由上可以添加動態(tài)字段來接受參數,稱為路徑參數。redirect的時候可以省略component配置。嵌套路由例外,如果一個路由記錄有children和redirect屬性,它也應該有component屬性。s

    //1. 自定義模版const User = {template:"<div>User</div>"}//2. 動態(tài)路由參數:id , 匹配到 /users/1 , /users/qq 等const router = [//path可以匹配多個路徑參數,/users/:id/details/:name{path:'/users/:id',compontent:User}]//3. 路由目標組件User中可以通過this.$route.params到形式獲取參數,json格式{id:1,name:'zqq'}const User = {template:"{{ $route.params.id }}"}

響應路由參數的變化
可以對同一組件路由參數變化做出響應,簡單的watch$route對象上的任意屬性

    //模版中,created函數,用this.watch觀察參數的變化const User{template:"<div>{{ this.$route.params }}</div>",created(){this.$watch(() => this.$route.params,(toParams,previousParams) =>{//路由參數變化的響應邏輯});}}

捕獲所有固定前綴路由或404 Not found路由

    //定義404路由匹配組件const NotFound = {template:"<div>{{ $route.params.pathMatch }}</div>"}//定義user-* 路由匹配組件const User = {template:"<div>{{ $route.params.users }}</div>"}//定義路由const routes = [//匹配所有其它路由沒有匹配到的路徑,并且放在pathMatch下,通過$route.params.pathMatch訪問匹配的所有路徑,路徑/a/b -> ["a","b"]{path:'/:pathMatch(.*)*',component:NotFound},//匹配所有的user-前綴的路徑,路徑user-123 -> 123{path:'/user-:users(.*)',component:User}]

嵌套路由

一些應用的UI由多層嵌套的組件組成,組件之中套著組件,可以使用嵌套路由表達這種關系,``children`關鍵字。

    //1. 定義一個組件,組件中嵌套著路由模版 <router-view>const home = {template:'<div>home組件</div><router-view></router-view>'}//定義一個子組件const child = {template:'<div>子組件</div>'}//2. 定義一個路由,包含子路由(嵌套路由)const routes = [{path:'/home',component:home,children:[{path:'hello',component:child}]}]

編程式導航

在Vue實例中,可以通過$router訪問路由實例,因粗可以通過編程式導航,調用$router實現路由跳轉。

//字符串路徑
router.push('/user/detail')//傳入對象路
router.push({path:'/user/detail'})//命名的路由,并加上參數,讓路由建立url
router.push({name:'user',params:{username:'zqq'}})//帶查詢參數,結果是register?plan=private
router.push({path:'register,query:{plan:'private'}'})//帶hash,結果是/about#team
router.push({path:'/about',hash:'#team'})

命名路由

除了path之外,可以為路由提供name

    const routes = [{path:'/user/:username',name:'user',component:User}]//導航到命名路由//1. 聲明式<router-link :to="{name:'user',params:{username:'zqq'}}">User</router-link>//2. 編程式router.push({name:'user',params:{username:'zqq'}})

命名視圖

有時候想同時展示同級多個視圖,而不是嵌套,如頁面的head、body、foot等??梢栽诮缑鎿碛卸鄠€單獨命名的視圖router-view,而不是只有一個單獨的視圖。

    //組件const About = {template:'<div>This is about</div>'}//創(chuàng)建多個路由視圖,并命名<router-view name="leftSidebar"></router-view>//沒有設置名詞,默認為default<router-view></router-view><router-view name="rightSidebar"></router-view>//創(chuàng)建路由對象,指定渲染的視圖const routes = [{path:'/about',components:[leftSidebar:About]}]

重定向和別名

重定向也是通過routes配置來完成

    //從 home重定向到aboutconst routes = [{path:'/home',redirect:'/about'}]//重定向到目標也可以是一個命名的路由const routes = [{path:'/home',redirect:{name:'about'}}]//重定向到方法,動態(tài)返回重定向目標const routes = [{path:'/search/:searchText',redirect:to =>{//觸發(fā)的路由作為參數,toreturn {path:'/search',query:{q:to.params.searchText}}},//重定向這個路由{path:'/search'component://組件}}]

別名

可以為路由配置一個別名alias,用戶訪問別名的地址相當于訪問真實的path。如果路由有參數,需要在別名中包含它們。

    //這個路由在瀏覽器訪問/user 或 /users都會渲染UserComponent組件const routes = [{path:'/user',component:UserComponent,alias:'/users' //可以使用數組,['/users','/u']}]

路由組件傳參

當路由的設置propstrue的時候,參數會被設置到組件props里。

    //定義組件 ,這里直接用{{ id }}獲取路由的參數,而不是this.$roter.paramsconst home = {props:['id'],template:'<div>{{ id }}</div>',}//路由配置const routes = [{path:'/home/:id',component:home, //對于有命名的視圖,需要為每個視圖開啟配置//{default:true,other-view;true}props:true}]

不同的歷史模式

在創(chuàng)建路由器實例時,history配置允許為們在不同的歷史模式中進行選擇。

  1. Hash模式
    Hash模式時用createWebHashHistory創(chuàng)建的,它是在內部傳遞的實際URL之前使用一個哈嘻字符(#)。由于這部分URL從未被發(fā)送到服務器,所有它不需要在服務器層面上進行任何特殊處理。不過URL類似這樣https://127.0.0.1:8080/index.html#home
        import (createRouter,createWebHashHistory) from 'vue-router'const router = createRouter({history:createWebHashHistory(),routes:[//......]});
    
  2. HTML5模式
    createWebHistory創(chuàng)建HTML5模式,使用這種模式URL類似http://127.0.0.1:8080/user/id。不過由于應用時一個單頁面的客戶端應用,需要有對應的服務端配置,否則會得到404錯誤。
        const router = createRouter({history:createWebHistory(),routes:[//......]});
    
http://www.risenshineclean.com/news/62156.html

相關文章:

  • 網站關鍵詞排名優(yōu)化技巧鐘南山今天感染新冠了
  • 無錫網站建設制作開發(fā)廣西seo搜索引擎優(yōu)化
  • 網站開發(fā)費怎么做會計分錄做app的網站
  • 自己注冊網站靜態(tài)網頁制作
  • 工廠找訂單哪個平臺最好舉例說明seo
  • 永嘉縣住房建設局網站百度seo排名如何提升
  • apache 配置網站百度資訊
  • 昆明網站建設公司_百度推廣怎么提高關鍵詞排名
  • 寧波專門做網站武漢大學人民醫(yī)院精神科
  • 宣城市建設監(jiān)督管理局網站下載企業(yè)宣傳網站
  • 婚慶網站源碼網絡銷售推廣公司
  • 軟件商城官網廈門seo
  • 武漢網站開發(fā)招聘如何推廣網頁
  • 建行官方網站優(yōu)化大師是什么軟件
  • ps怎么做網站橫幅廣告長沙h5網站建設
  • 做網站網頁建站企業(yè)網站
  • 沈陽做網站怎樣收費百度商業(yè)平臺官網
  • 醫(yī)院網站建設思路上海搜索引擎優(yōu)化公司
  • 營銷型網站建設 價格軟文案例400字
  • 房山區(qū)網站建設做網站
  • 美妝網站模版360優(yōu)化大師舊版本
  • 網站開發(fā)廈門廣告營銷案例100例
  • 網站開發(fā)什么語言友情鏈接可以隨便找鏈接加嗎
  • 宣城網站建設寧波seo網站服務
  • 做網站排名公司推薦網絡營銷方案例文
  • 福州便民網免費發(fā)布信息seo文章優(yōu)化技巧
  • 中企動力科技股份有限公司做網站網絡銷售是干嘛的
  • 西安網站建設維護如何申請一個網站域名
  • 有哪些幫別人做任務賺錢的網站網絡推廣員每天的工作是什么
  • 衡水做wap網站建設廣州網站優(yōu)化價格