亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

vue實(shí)現(xiàn)四級(jí)導(dǎo)航及驗(yàn)證碼的方法實(shí)例

瀏覽:17日期:2022-09-28 11:08:59
實(shí)現(xiàn)效果:

vue實(shí)現(xiàn)四級(jí)導(dǎo)航及驗(yàn)證碼的方法實(shí)例

首先創(chuàng)建五個(gè)vue界面

1.home.vue頁(yè)面

<template> <div id='home-wrapper'> <h1>{{ name }}</h1> <nav> <!-- 二級(jí)路由的出口 在一級(jí)路由的界面里面 --> <router-link to='/one'>one</router-link> <router-link :to='{ name: ’Two’ }'>two</router-link> <router-link :to='threeObj'>three</router-link> <!-- 編程式 導(dǎo)航/路由 --> <button @click='fourBtn'>four</button> </nav> <router-view></router-view> </div></template> <script>export default { data() { return { name: '首頁(yè)', threeObj: {name: 'Three', }, }; }, methods: { fourBtn() { var userId = 6789; this.$router.push({path: `four/${userId}`, }); }, },};</script> <style lang='less' scoped>#home-wrapper{ nav{ display: flex; a{ flex: 1; background-color: antiquewhite; height: 50px; line-height: 50px; } }}</style>

2.one.vue界面

<template> <div><h1>{{name}}</h1><ul> <li><router-link to='/levl31'>web</router-link> </li> <li><router-link :to='{name:’name32’}'>后端</router-link> </li> <li><!-- 使用命名路由 在多級(jí)路由里面 比較方便 --><router-link :to='{name:’name33’}'>AI</router-link> </li> <li><router-link to='/one/levl34'>UI</router-link> </li> <li><router-link :to='{name:’name35’}'>三級(jí)路由-4</router-link> </li></ul><!-- 三級(jí)路由 出門(mén)在二級(jí)路由的界面 --><router-view></router-view> </div></template> <script> export default {name:’One’,data() { return {name: '第一頁(yè)' }}, }</script> <style lang='less' scoped>ul{ list-style: none; display: flex; width: 100%; margin-left: -40px; }li{ flex: 1; background-color: orange; height: 50px; line-height: 50px; } </style>

3.two.vue頁(yè)面以及驗(yàn)證碼實(shí)現(xiàn)

實(shí)現(xiàn)效果圖:

vue實(shí)現(xiàn)四級(jí)導(dǎo)航及驗(yàn)證碼的方法實(shí)例

<template> <div> <h1>{{ name }}</h1> <button @click='changeCode'>驗(yàn)證碼</button> <img :src='http://www.aoyou183.cn/bcjs/imgCodeUrl' alt=''> </div></template> <script>export default { // 組件的別名 在vue調(diào)試的時(shí)候方便查看 name: 'Two_zh', data() { return { name: '第二頁(yè)', imgCodeUrl:'' }; }, methods: { // 獲取驗(yàn)證碼 changeCode() {// /api 是在vue.config.js 里面代理配置 const url = 'api/v1/captchas'; // const url = 'https://elm.cangdu.org/v1/captchas'; this.axios.post(url, {}).then((res) => { this.imgCodeUrl =res.data.code console.log('驗(yàn)證碼接口:',res);}).catch((e) => { console.log('錯(cuò)誤:', e);}); }, },};</script> <style lang='less' scoped></style>

4. three.vue頁(yè)面

<template> <div><h1>{{name}}</h1> </div></template> <script> export default {name:’three’,data() { return {name: '第三頁(yè)' }}, }</script> <style lang='less' scoped> </style>

5.four.vue頁(yè)面

<template> <div><h1>{{name}}</h1> </div></template> <script> export default {name:’Four’,data() { return {name: '第四頁(yè)' }},created() { console.log('第四頁(yè) created:',this.$route)}, }</script> <style lang='less' scoped> </style>

然后配置路由:

import Vue from ’vue’import VueRouter from ’vue-router’import Home2 from ’@/views/day/home.vue’ Vue.use(VueRouter) const routes = [ { path: '/', name: ’home2’, component: Home2, redirect: '/one', children: [ {path: '/one',name: ’One’,component: () => import('@/views/day/one.vue'),children: [ { path: ’/levl31’, // h creacteElemet 的意思 創(chuàng)建 虛擬Dom/標(biāo)簽 Vnode // 第一個(gè)參數(shù)是 標(biāo)簽名 擴(kuò)展的話 自己的寫(xiě)的組件 也是標(biāo)簽名 // 第二個(gè)參數(shù)是 可選的 標(biāo)簽的屬性配置 // 第三個(gè)參數(shù)是 標(biāo)簽的內(nèi)容 component: { render(h) {return h('h1', '前端') } }, }, { // /默認(rèn)代表根目錄 #/levl31 // 不帶斜杠 會(huì)自己拼接 #/one/levl32 // 使用的時(shí)候統(tǒng)一用命名路由 path: 'levl32', name: 'name32', component: { render(h) {return h('h1', '后端')} }, }, { path:'/one?levl33', name:'name33', component:{render(h) { return h('h1', '人工智能') } } }, { path:'/one/levl34', name:'name34', component:{render(h) { return h('h1','就是個(gè)美工嗎') } } }, // 三 四級(jí)路由 { path:'level35', name:'name35', component:()=>import('@/views/Home.vue'), // 四級(jí)路由 children:[{ path:'boy', name:'Boy', component:()=>import('@/views/boy.vue')},{ path:'girl', name:'Girl', component:()=>import('@/views/girl.vue')} ] }] }, {path: '/two',name: ’Two’,component: () => import('@/views/day/two.vue') }, {path: '/three',name: ’Three’,component: () => import('@/views/day/three.vue') }, {// 可選參數(shù) d 數(shù)字 字符串就匹配不上path: 'four/:id(d*)?',name: ’Four’,component: () => import('@/views/day/four.vue') }, ] }] const router = new VueRouter({ routes}) export default router總結(jié)

到此這篇關(guān)于vue實(shí)現(xiàn)四級(jí)導(dǎo)航及驗(yàn)證碼的文章就介紹到這了,更多相關(guān)vue四級(jí)導(dǎo)航及驗(yàn)證碼內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 国产三级三级三级三级 | 中国特级黄一级真人毛片 | 极品销魂一区二区三区 | 岛国激情片 | 4438成人成人高清视频 | 在线不卡一区二区 | 国产中的精品一区的 | 欧美在线黄色 | 亚洲免费人成 | 中国女人一级片 | 超级碰碰碰在线观看 | 久久综合狠狠综合久久综合88 | 日韩a级片在线观看 | 亚洲无线一二三四区 | 尤物视频在线观看入口 | 青青在线香蕉精品视频免费看 | 伊人久久综合网站 | 国产网站大全 | 国产美女久久久久久久久久久 | 色久视频 | 久久受www免费人成看片 | 免费国内精品久久久久影院 | 久久精品免费一区二区视 | 国产成人久久综合二区 | 日韩成人午夜 | 欧美综合亚洲图片综合区 | 国产成人精品曰本亚洲78 | 奇米影视大全 | 国产91po在线观看免费观看 | 老头边吃奶边做边爱 | 成人性视屏 | 国语性猛交xxxx乱大交 | 日韩精品一区二区三区中文字幕 | 黄色一级视频免费观看 | 在线看片 在线播放 | aaaaaa精品视频在线观看 | 亚洲一区二区三区不卡在线播放 | 亚洲经典一区二区三区 | 亚洲福利视频在线 | aaaa一级片| 免费看一级特黄a大片 |