vue 路由傳參(後臺數據)

1.在方法裏面傳參(cantingid是之前通過請求接口拿到的)

<div class="DIV" @click="goto(cantingid)"></div>

2.路由傳參

goto(id){             //cantingid=id
     this.$router.push({name:'foodinfo',query:{cid:id}})         //將餐廳id傳值給下一個頁面用cid接收
}

3.接收傳參

this.$route.query.cid 
 getapp(){
            this.cid=this.$route.query.cid 
            this.type=this.$route.query.type
            this.axios.getrestaurantmenulist({
                restaurantId:this.cid,
                type:this.type
            }).then(res=>{
                this.alldata=res.data;
            }).catch(res=>{

            }),
            //菜系名稱查詢
            this.axios.getkindlistbytype({
               params:{type:this.type}
            }).then(res=>{
                this.option=res.data
            }).catch(res=>{

            })
        },

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章