• vue-router核心概念


    vue用来实现SPA的插件

        使用vue-router

            1. 创建路由器: router/index.js

              new VueRouter({

                routes: [

                  { // 一般路由

                    path: '/about',

                    component: about

                  },

                  { // 自动跳转路由

                    path: '/', 

                    redirect: '/about'

                  }

                ]

              })

            2. 注册路由器: main.js

               import router from './router'

               new Vue({

               router

               })

            3. 使用路由组件标签:

               <router-link to="/xxx">Go to XXX</router-link>

               <router-view></router-view>

        编写路由的3步

            1. 定义路由组件    

            2. 映射路由

            3. 编写路由2个标签

        嵌套路由

            children: [

                {

                  path: '/home/news',

                  component: news

                },

                {

                  path: 'message',

                  component: message

                }

             ]

        向路由组件传递数据

            params: <router-link to="/home/news/abc/123">

            props: <router-view msg='abc'>

        缓存路由组件

            <keep-alive>

              <router-view></router-view>

            </keep-alive>

        路由的编程式导航

        this.$router.push(path): 相当于点击路由链接(可以返回到当前路由界面)

        this.$router.replace(path): 用新路由替换当前路由(不可以返回到当前路由界面)

        this.$router.back(): 请求(返回)上一个记录路由

  • 相关阅读:
    参数方法HttpServletRequest之getParameter
    nullnull单例的实现方式之GCD方法
    阻带窗函数[数字信号处理]使用窗函数设计FIR滤波器
    nullnullhdu4450Draw Something
    第三方设置XML解析:第三方库GDataXMLNode的使用
    class左边nbu 2414 Please help the poor donkey!
    数据可视化可视化营养含量
    速度坐标hdu4445Crazy Tank
    singletonclassDesign Patterns: Singleton Basics 设计模式:单例基础
    控制台权限MMC不能打开文件 SQL Server Enterprise Manager.MSC 或权限不够 (解决方法 )
  • 原文地址:https://www.cnblogs.com/songhongye/p/10375545.html
Copyright © 2020-2023  润新知