<span class="unfollow" @click="follow(data.user.id, $event)">关注</span>
follow(user_id, event) {
      console.log(user_id)
      this.$axios.post('/api/user/follow', {
        follow_user_id: user_id
      }).then(response => {
        let data = response.data
        if(data.status == 200) {
          let el = event.target
          console.log(event)
          if (data.data.status == 9) {
            el.innerHTML = '关注';
            el.className = "unfollow";
          } else {
            el.innerHTML = '取消关注';
            el.className = "followed";
          }
        } else {
          this.$weui.toast(data.msg)
        }
      }).catch(error => {
        this.$weui.toast(error)
      })
    }

 

Logo

前往低代码交流专区

更多推荐