通过get请求到的TotalComment,如何赋值给data里的totalComment
export default {
data() {
return {
contentId:1,
focusflag:true,
totalComment:TotalComment,
reply:'',
name:'金医生',
articleContent:'',
active:'',
commentList:commentList,
goodCommentList:goodCommentList,
totalComment:TotalComment,
}
},
methods: {
//获取全部评论
getAllComment:function () {
Axios({
// `url` 是用于请求的服务器 URL
url:devhttpUrl + '/content/comments/all?contentId='+1+'&pageNo=1&pageSize=20&totalItems=-1',
// `method` 是创建请求时使用的方法
method: 'get', // 默认是 get
headers: {'Authorization':'Bearer '+ token },
// data:postData
}).then(function (result) {
if(result.data.errCode==0){
var dataobj=result.data.data.items;
TotalComment=result.data.data.totalItems;
console.log(TotalComment)
for(var i=0;i
commentList.push({id:dataobj[i].id,name:dataobj[i].userNickName,time:dataobj[i].creationTime,replyNo:dataobj[i].replyCount,cool:dataobj[i].likeCount,content:dataobj[i].content})
}
}
else{
Toast(result.data.errMsg);
}
console.log(TotalComment)
//that.$set(that,'totalComment',TotalComment);
}).catch(function (error) {
console.log(error)
})
}