index.js

{
path:"/blog/:id",
name:"SingleBlog",
component:SingleBlog
}

 

1.<router-link v-bind:to="'/blog/' + blog.id"> <h2 v-color="">{{blog.title}}</h2> </router-link>列表页面跳转

2  详情页面

<script>
export default{
name:"single-blog",
data(){
return{
id:this.$route.params.id,
blog:{}
}
},
created(){
// console.log(this.id)
this.$http.get('https://jsonplaceholder.typicode.com/posts/'+this.id)
.then(function(data){
console.log(data)
this.blog=data.body
})
.then(function(data){
this.blog = data.body
})
},
}
</script>

相关文章:

  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-02-02
  • 2023-03-04
  • 2021-11-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-11-21
相关资源
相似解决方案