从商品页面获取商品的id获取不到?
在商品页面除了id给详情页面,但是详情页面拿不到id是怎么原因,求大神帮忙看一下哪里写错了?
商品页面代码:
<ul class="recommend_left_main"> <li v-for="(item2,index) in recommendshop" :key="index"
@click="pushdetails()">
<div class="recommend_left_main_img">
<img :src="item2.img" />
</div>
<div
class="recommend_left_main_describe"
:title="item2.describe"
>
{{ item2.describe | aa }}
</div>
<p class="recommend_left_main_num">¥{{ item2.price }}</p>
</li>
</ul>
//跳转详情 pushdetails(id){
this.$router.push({
name:'ProductDetails',
query:{
id:this.id
}
})
},
在详情页面进行接收的代码:
created(){ this.id=this.$route.query.id;
console.log(this.id)
this.getGoodsInfo();
},
methods:{
getGoodsInfo(){
let that=this;
this.axios
.studentFindProdutDetails({
id:that.id
})
.then((res) =>{
console.log(res.data.data)
})
.catch((err) =>{})
}
}
回答:
<li v-for="(item2,index) in recommendshop" :key="index" @click="pushdetails(item2.id)">
给id赋值
pushdetails(id){
this.id=id;
this.$router.push({
name:'ProductDetails',
query:{
id:this.id
}
})
},
以上是 从商品页面获取商品的id获取不到? 的全部内容, 来源链接: utcz.com/p/935777.html