zoukankan      html  css  js  c++  java
  • 动态路由

    首页

        // 进入详情
            detail(id){
                console.log("详情")
                this.$router.push({path:'./detail/'+id})
            }   

      //传参 (在 query 里面)
        this.$router.push({path: '/product/buy',    query: {  orders: JSON.stringify(orders)  ,  total: orders[0].totalAmount  ,  stock: this.select  }  })
     
       // 下个页面接收
        
        this.orders = JSON.parse(this.$route.query.orders)

    详情页

    methods:{
            load(){
                this.getDetail()
                console.log("路由的id")
                console.log(this.$route.params.id)
                this.detailId = this.$route.params.id
            }
        }

    $router 和 $route的区别

    $router是VueRouter的实例,在script标签中想要导航到不同的URL,使用$router.push方法。

    返回上一个历史history用$router.to(-1)

    $route为当前router跳转对象。里面可以获取当前路由的name,path,query,parmas

  • 相关阅读:
    powershell,系统学习的第一种脚本语言
    mysql的source命令
    timer--计时器
    document.write 方法
    数组去重
    Abdicate
    轮播图
    使用 margin 让div块内容居中
    模运算 NOJ 1037
    模运算 NOJ 1037
  • 原文地址:https://www.cnblogs.com/ll15888/p/11585606.html
Copyright © 2011-2022 走看看