uniapp评论列表插件获取

从评论列表,回复,点赞,删除,留言板 - DCloud 插件市场里导入,并使用。

代码样式优化及接入如下:






页面接入:


		   
	   

getTree(data) {
			    let result = [];
			    let map = {};
			    data.forEach(item => {
			        map[item.id] = item;
			    });
			    data.forEach(item => {
			        let parent = map[item.parentId];
			        if (parent) {
			            (parent.children || (parent.children = [])).push(item);
			        } else {
			            result.push(item);
			        }
			    });
			    return result;
			},
			bindTextAreaBlur: function (e) {
				console.log(e.detail.value)
			},
			focusOn(){
				this.$refs.hbComment.focusOn();
			},
			sendComment(data){
				var type=0
				if(data.pId){
					type = 1;
				}
				var form = {"content":data.content,"blogId":this.item.id,"type":type,"parentId":data.pId};
				addCommentBlog(form).then(response=>{
					this.$refs.hbComment.closeInput();
					this.getCommentList();
				})
			},
			delcomment(data){
				delcomment(data).then(response=>{
					this.getCommentList();
				})
			},
			getCommentList(){
				listCommentBlogMinApp({"blogId":this.item.id}).then(res=>{
					// res.readNumer = 193;
					res.commentList=res.data.rows;
					this.commentData = {
					    "readNumer": res.readNumer,
					    "commentSize": res.commentList.length,
					    "comment": this.getTree(res.commentList)
					}
				})
			},

你可能感兴趣的:(前端,uni-app)