• VUE通过id从列表页跳转到相对的详情页


    新闻列表页面:

      在这里我用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传过去啦

     

  • 相关阅读:
    Beta冲刺 5
    Beta冲刺 4
    Beta冲刺 3
    Beta冲刺 2
    Beta冲刺 1
    项目评测博客
    Beta冲刺前准备
    Alpha 冲刺11——总结
    Alpha冲刺10
    Alpha冲刺9
  • 原文地址:https://www.cnblogs.com/eyed/p/7866951.html
Copyright © 2020-2023  润新知