Main.js, 路由页面
- {
- path: '/customer/:id',
- component: CustomerDetails
- }
父页面
- <router-link class="btn btn-default" v-bind:to="'/customer/'+customer.id"> 详情 </router-link>
- methods:{
- fetchCustomers(id) {
- this.$http.get("http://localhost:3000/users/"+id http://localhost:3000/users/%22+id )
- .then(res => {
- //console.log(res.body);
- this.customer = res.body;
- });
- // axios.get("users").then(res=>{
- // console.log(res.data)
- // })
- },
接收对应的每个 id
- created(){
- this.fetchCustomers(this.$route.params.id)
- }
来源: http://www.qdfuns.com/article/42874/e5d07bf014e33407f2c823124cef99ee.html