Click on the details to jump to another page, requiring to carry the current id
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="">