vuerouter-6_路由杂项

Posted xiao-peng-ji

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vuerouter-6_路由杂项相关的知识,希望对你有一定的参考价值。

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_路由杂项的主要内容,如果未能解决你的问题,请参考以下文章

vuerouter-7._路由高亮

杂项_宽带信息泄露

Vue路由系统详述 -- 2019-08-08 18:01:24

VueRouter爬坑第四篇-命名路由编程式导航

vue,VueRouter路由使用

VueRouter路由跳转报错:vue-router.esm.js?fe87:2100 Uncaught (in promise) NavigationDuplicated