成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來到九壹網(wǎng)。
搜索
您的當(dāng)前位置:首頁vue路由嵌套的SPA實(shí)現(xiàn)步驟

vue路由嵌套的SPA實(shí)現(xiàn)步驟

來源:九壹網(wǎng)

本文為大家分享了路由嵌套的SPA實(shí)現(xiàn)的步驟:

A(/a)組件需要嵌套B組件(/b)和C組件(/c)

①準(zhǔn)備嵌套其它組價(jià)的父組件 指定一個(gè)容器

在A組件指定一個(gè)容器
<router-view></router-ivew>

②在A組件的路由配置對(duì)象中指定children屬性

{
path:'/a',
component:A,
children:[
{path:'/b',component:B},
{path:'/c',component:C},
]
}

補(bǔ)充:

//數(shù)字如果超出記錄的次數(shù),是不行的。
this.$router.go(num);
如果num是正數(shù),向前進(jìn)
如果num是負(fù)數(shù),向后退

代碼

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>路由嵌套</title>
 <script src="js/vue.js"></script>
 <script src="js/vue-router.js"></script>
 </head>
 <body>
 <div id="container">
 <p>{{msg}}</p>
 <router-view></router-view>
 </div>
 <script>
//登錄組件
 var myLogin = Vue.component("login",{
 template:`
 <div>
 <h1>登錄組件</h1>
 <router-link to="/mail">登錄</router-link>
 </div>
 `
 })
// 郵箱頁面
 var myMail = Vue.component("mail",{
// 定義一個(gè)返回的方法
 methods:{
 goBack:function(){
 this.$router.go(-1);
 }
 },
 template:`
 <div>
 <h1>郵箱主頁面</h1>
 <ul>
 <li>
 <router-link to="/inbox">收件箱</router-link>
 </li>
 <li>
 <router-link to="/outbox">發(fā)件箱</router-link>
 </li>
 </ul>
// 點(diǎn)擊按鈕返回前面的頁面
 <button @click="goBack">返回</button>
 <router-view></router-view>
 </div>
 `
// 指定一個(gè)容器,加載收件箱或收件箱的列表
 })
// 收件箱組件
 var myInBox = Vue.component("inbox-component",{
 template:`
 <div>
 <h4>收件箱</h4>
 <ul>
 <li>未讀郵件1</li>
 <li>未讀郵件2</li>
 <li>未讀郵件3</li>
 </ul>
 </div>
 `
 })
// 發(fā)件箱組件
 var myOutBox = Vue.component("outbox-component",{
 template:`
 <div>
 <h4>發(fā)件箱</h4>
 <ul>
 <li>已發(fā)送郵件1</li>
 <li>已發(fā)送郵件2</li>
 <li>已發(fā)送郵件3</li>
 </ul>
 </div>
 `
 })
 //配置路由詞典
 new Vue({
 router:new VueRouter({
 routes:[
 {path:'',redirect:'/login'},
 {path:'/login',component:myLogin},
 {path:'/mail',component:myMail,children:[
 {path:'/inbox',component:myInBox},
 {path:'/outbox',component:myOutBox}
 ]},
 ]
 }),
 el:"#container",
 data:{
 msg:"Hello VueJs"
 }
 })
 //通過再次指定一個(gè)<router-view></router-view>和children:[]
 </script>
 </body>
</html>

Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號(hào)-2

違法及侵權(quán)請(qǐng)聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)