vue点击修改当前dom的值和class
<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(respo
·
<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)
})
}
更多推荐
已为社区贡献4条内容
所有评论(0)