zoukankan      html  css  js  c++  java
  • router和route的理解

    $router : 是路由操作对象,只写对象

    $route : 路由信息对象,只读对象

    如果要在刷新页面的时候通过路由的信息来操作数据,可以在created下
    使用this.$route 这个的属性
    this.$route 存着一些与路由相关的信息
    常用的:
    parmas 预设的变量
    path 当前的路由的路径
    query 查询信息 ?号
    hash hash信息 #号
     
    操作 路由跳转
    this.$router.push({
          name:'hello',
          params:{
              name:'word',
              age:'11'
         }
    })

    读取 路由参数接收
    this.name = this.$route.params.name;
    this.age = this.$route.params.age;
     
     

     

    router.go(n)
    这个方法的参数是一个整数,意思是在 history 记录中向前或者后退多少步,类似 window.history.go(n)

    router.push(location)
    想要导航到不同的 URL,则使用 router.push 方法。这个方法会向 history 栈添加一个新的记录,所以,当用户点击浏览器后退按钮时,则回到之前的 URL。

    router.replace(location)
    跟 router.push 很像,唯一的不同就是,它不会向 history 添加新记录,而是跟它的方法名一样 —— 替换掉当前的 history 记录。

     

    代码的世界很精彩,好的代码需要慢慢的打磨。
  • 相关阅读:
    hashCode花式卖萌
    2017年的小总结
    多线程环境下的单例模式
    Servlet过滤器简单探索
    最长回文子序列(LPS)
    最短编辑距离问题
    赫夫曼编码
    DNA序列对齐问题
    同时寻找序列的最大最小值
    最长公共子序列(LCS)
  • 原文地址:https://www.cnblogs.com/Allisson/p/10253284.html
Copyright © 2011-2022 走看看