今天我们使用编程式导航的方式进行页面的跳转 把id=1传过去
goSearch1(){
this.$router.push({path:'/shangDian',query:{id:'1'}})
}
在点击后进入的页面我们要将id=1 拼接到url中 使用的是模版字符串
公共路径后要加上 ? 再加上要拼接的部分
axios({
url:`http://49.234.47.141:8112/GetStore?id=${this.$route.query.id}`,
method:"GET"
})
顺便讲一讲 params和query传参的区别
query语法:
this.$router.push({path:"地址",query:{id:"123"}}); 这是传递参数
this.$route.query.id; 这是接受参数
params:语法
this.$router.push({name:"地址",params:{id:"123"}}); 这是传递参数
this.$route.params.id; 这是接受参数
具体的看一看这个