zoukankan      html  css  js  c++  java
  • Vue:路由router的一些用法

     

    Vue-router的引入

    分为两种方式:

    1.通过npm 引入vue-router库

    npm install vue-router

    在模块中通过下面的方法使用

    import Vue from 'vue'
    import VueRouter from 'vue-router'
    
    Vue.use(VueRouter)

    2.直接通过script标签引入vue-router.js文件

    如果是通过script标签引入,则直接使用即可。

    下载地址

    router的使用

    var routes = [
            {
                path:'/home',
                component:home,
                name:"home"
            },
            {
                path:'/order',
                component:order,
                name:"order",
                redirect:'/order/all',  /*默认子路由*/
                children:[
                    {
                        path:'all',
                        component:all,
                        name:'allOrder'
                    },
                    {
                        path:'having',
                        component:having,
                        name:'havingOrder'
                    },
                    {
                        path:'had',
                        component:had,
                        name:'hadOrder'
                    }
                ]
            },
            {path:'/self',component:_self,name:"self"}
        ]

    这里是我自己的一些应用心得。如果有什么问题,欢迎留言~

    官方文档

  • 相关阅读:
    Vue生命周期
    事件
    改变this指向
    全屏要素
    微信小程序
    编程心得
    设计模式-单例与实例化
    第五节课 课堂总结
    作业四 分支结构
    课堂总结
  • 原文地址:https://www.cnblogs.com/WQLong/p/8298291.html
Copyright © 2011-2022 走看看