Use $router.push to carry parameters for page jump

insert image description here
Click on the details to jump to another page, requiring to carry the current id
insert image description here
Realization: use router.push to jump, splicing id

    // 详情按钮
    clickProductInfoButt (id) {
    
    
      // console.log(111)
      this.$router.push('/manage_products/product_info?id=' + id)
    }

Get the id in created in another page and
try to render a picture

data () {
    
    
    return {
    
    
      id: '',  //传入的id
      imgUrl: '',
    }
  },
created () {
    
    
    if (this.$route.query.id != undefined) {
    
    
      this.id = this.$route.query.id
    }
    this.productInfo()
  },
  methods: {
    
    
    productInfo () {
    
    
      var that = this;
      getBigProductInfo({
    
     token: getToken(), id: that.id }).then(res => {
    
    
        console.log(res)
        that.imgUrl = res.img
      })
    }
  }
<img :src="imgUrl"  alt="">

Guess you like

Origin blog.csdn.net/weixin_55966654/article/details/121340429