zl程序教程

您现在的位置是:首页 >  其他

当前栏目

vue.js客服系统实时聊天项目开发(九)热门常问关键词展示

2023-03-07 09:42:37 时间

在聊天输入框的上方,一般会展示一些常问的关键词,访客点击以后直接回复设置的回答

展示效果如下图所示:

直接通过接口获取数据,循环展示数据就可以了

            //获取常问关键词
            getTopRequest(){
                var _this=this;
                let entId=tools.getQuery("ent_id");
                this.visitor.ent_id=entId;
                this.$axios.get(this.ApiHost+'/other/getTopQuestion?ent_id='+entId).then(function (response) {
                    let result=response.data.result;
                    if(result.hotQuestion){
                        let hotQuestion=result.hotQuestion.replace(",",",").split(",");
                        _this.question.hotQuestion=hotQuestion;
                    }

                    console.log(hotQuestion);
                }).catch(function (error) {
                });
            },

模板中循环数组

            <div class="hotQuestions" v-if="question.hotQuestion.length!=0">
                <a class="slideInRightItem"  v-for="row in question.hotQuestion">{{row}}</a>
            </div>