zoukankan      html  css  js  c++  java
  • 使用路由传递信息

    0. 需求

    在某个页面获得前个页面的东西,因为不是父子级关系,显然就整路由传参比较OK

    1. 路由

    //$router : 是路由操作对象,只写对象
    //$route : 路由信息对象,只读对象
    
    //操作 路由跳转
    this.$router.push({
          name:'hello',
          params:{
              name:'word',
              age:'11'
         }
    })
    
    //读取 路由参数接收
    this.name = this.$route.params.name;
    this.age = this.$route.params.age;
    

    2. param与query

    使用params传参只能使用name进行引入路径

    使用query传参Name path都可以引入路径

    所以query使用更广!!!用query就完事了嗷。

    3. 小小BUG

    created() {
        let deliver = this.$route.query?.deliver;
        if (deliver ?? null) {
          this.queryForm = deliver;
        }
        this.fetchData();
      },
    

    如果直接等于,再次刷新抵达的界面,就会爆红,原因是对象地址指向了1个虚无的东西。这种情况下,记得把传过来的这玩意深拷贝1下就好了。

    this.queryForm = Object.assign({}, deliver);

  • 相关阅读:
    并列显示
    vertical-align,text-align 和 align的区别
    实现水平垂直居中
    overflow属性
    float属性
    table 标签
    idea中修改默认maven
    使用host的方式来破解idea
    mysql分区
    mysql数据库设计规范
  • 原文地址:https://www.cnblogs.com/lepanyou/p/15597269.html
Copyright © 2011-2022 走看看