码迷,mamicode.com
首页 > 其他好文 > 详细

vuerouter-6_路由杂项

时间:2019-08-11 23:23:16      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:网络学习   ase   --   http   params   style   turn   children   direct   

1.重定向

2.404

3.mode:"history"

4.this.$route.path

实例-------------------------------------------------------

import Vue from ‘vue‘
import VueRouter from ‘vue-router‘
//@表示寻找根目录
import HelloWorld from ‘@/components/HelloWorld‘
import learn from ‘@/components/learn‘
import Basee from ‘@/components/basee‘
import Http from ‘@/components/http‘
import NotFound from ‘@/components/404‘

Vue.use(VueRouter)
//创建路由
export default new VueRouter({
//mode:‘history‘,
routes: [{
path: "/h/:id",
name: "HelloWorld", //可以作为跳转使用
component: HelloWorld
},
{
path: "/learn/:id",
name: "learn",
component: learn,
children: [{
path: "basee",
component: Basee
},
{
path: "http",
component: Http
}
]
},
{
path:"/",
//重定向
redirect:"/learn"
},
{
path:"*",
//404
component:NotFound
}
]
})

实例---------------------------------------------------------------------------------

<template>
<div class="learn">learn
{{this.$route.params.id}}
<ul>
<router-link to="/learn/basee" tag="li">基本学习</router-link>
<router-link to="/learn/http" tag="li">网络学习</router-link>
</ul>
<router-view />
<p>{{getUrl}}</p>
</div>
</template>

<script>
export default {
name:"learn",
data(){
return{

}
},
computed:{
getUrl(){
return this.$route.path;
}
}
}
</script>

<style lang="css" scoped>
</style>

vuerouter-6_路由杂项

标签:网络学习   ase   --   http   params   style   turn   children   direct   

原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11336904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!