首页 > 其他 > 详细

VUE通过id从新闻列表跳转到相对的新闻详情

时间:2017-11-20 17:12:01      阅读:1048      评论:0      收藏:0      [点我收藏+]

新闻列表页面:

  在这里我用a标签进行跳转,在vue里面可以这样写<router-link></router-link>

  <router-link :to="{path:‘/news‘,query:{ id:item.NewsID }}" class="around"></router-link>

新闻详情页:

  1)首先要获取id

  var newsID=this.$route.query.id;

  2)拼接到url上面

  this.$http.get(this.$store.state.index.ip + ‘/api/News/‘+newsID)

  

created: function() {
    var newsID=this.$route.query.id;
    this.$http.get(this.$store.state.index.ip + ‘/api/News/‘+newsID).then((response) => {
        console.log(response);
    }).catch(function(error) {
        console.log(error);
    });
}

  这样就可以把id传过去啦

 

VUE通过id从新闻列表跳转到相对的新闻详情

原文:http://www.cnblogs.com/eyed/p/7866951.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!