单击后组件不会重新呈现

时间:2019-04-01 09:43:10

标签: vuejs2

我有一个名为timeline.vue的组件,我正在根据路由URL在其中显示数据。当url为/ timeline / 1时,它显示数据,但是当我想从/ timeline / 1返回至/ timeline url(无id)时,它不会重新呈现页面,并且数据不会更改。请帮助。

 if(this.$route.path.includes(this.$route.params.userId))
  {
  this.donotShowTimeline = false;
  this.showTimeline = true;
  axios.get('http://localhost:8000/api/abc/'+this.$route.params.userId, 
 {headers:{'Authorization': 'Bearer '+token}})
 .then(
  response =>
 {
  console.log(response.data.userPosts);
  if(response.status === 200)
  {
  console.log(response.data.userPosts[0].artist);                      
  console.log("Company",response.data.userPosts[0].company);
  this.artistProfilePic = response.data.userPosts[0].artist;
  if(response.data.userPosts[0].artist)
  {
   console.log("inside Artist If");
   this.artistProfilePic = response.data.userPosts[0].artist;
   console.log(this.artistProfilePic.profilePicUrl); }
   else if (response.data.userPosts[0].company)
    {
     this.artistProfilePic = response.data.userPosts[0].company;
    }

    this.allPostsOfThisUser = response.data.userPosts;
    console.log(this.allPostsOfThisUser);
    console.log(response.data.userPosts.length);
    if(response.data.userPosts.length === 0)
    {
    console.log("This user posted Nothing");
    this.noPostByThisUser=true;
    }
    }
    }
    ).catch(
    (error)=>console.log(error)
    )
    }


    else 
    {
     ...
    }

0 个答案:

没有答案