创新实训【13】——热词信息查看功能

主要内容

这篇主要记录网页中具体热词展示的功能,展示了热词的名称,出现的次数,来源,以及相关的热词,点击具体的相关热词,可以看到相关热词的信息,可以通过点击网页链接,查看有关这个热词的网页。

网页展示

热词展示:
在这里插入图片描述
点击相关热词,可以展示这个热词的信息
在这里插入图片描述
点击网页链接,可以查看有关这个热词的网页:
在这里插入图片描述

主要步骤

1.前端网页的布局,主要有一个el-card卡片,展示热词信息

<template>
    <div>

  <el-card class="box-card"  style="margin-left:200px">
  <div slot="header" class="clearfix">
    <b><span>{{KW}}</span></b>
    <div style="float:right">
     <el-button plain @click="getlianjie()" >网页链接</el-button>
     </div>
  </div>
      
      
          <div  class="text item">
                  <b> <span>热词名称: </span><span>{{ KW}}</span></b>
             </div>
             <div  class="text item">
                  <b> <span>出现次数: </span><span>{{ times}}</span></b>
             </div>
             <div  class="text item">
                  <b> <span>来源: </span><span>{{ sources}}</span></b>
             </div>
           <div  class="text item">
               <el-row >
                  <b> <span>相关热词:</span> <span  v-for="item in otherKW"  :key="item"> <el-link  @click="xiangguan(item)">{{item}}</el-link></span></b>
               </el-row>
             </div>
            
  </el-card>
  </div>
</template>

2.因为是在热词查询列表中点击某个热词,展示这个热词的信息,首先展示网页中created方法,获取展示的热词KW,执行this.getInfo()获得热词的信息。

created(){
           
           this.KW=this.$route.query.KW;
           this.getInfo();
    },

getInfo()方法,从后端获取信息

 async getInfo(){
       console.log(this.KW);
       const query={};
       query.KW=this.KW;
       const {data:res}= await this.$http.post("KWinfo",query);
       console.log(res.flag,res.flag=="false");
       if(res.flag=="false")
             return;
       this.times=res.times;
       this.days=res.days;
       this.months=res.months;
       this.years=res.years;
       this.sources=res.sources;
       this.otherKW=res.otherKW;
     },

3.后端获得这个热词的信息

@RequestMapping("/KWinfo")
    public String KWinfo(@RequestBody String data ) {
        JSONObject datajson= JSONObject.parseObject(data);
        System.out.println(datajson);
        String kw=datajson.getString("KW");
        KW m=kwdao.getKWInfo(kw);
        if(m==null){
            HashMap<String,Object> res =new HashMap<>();
            res.put("flag","false");
            String res_json=JSON.toJSONString(res);
            System.out.println(res_json);
            return res_json;
        }
      
        String[] otherKW=m.getOtherKW().split(",");
        HashMap<String,Object> res =new HashMap<>();
        res.put("times",m.getTimes());
        res.put("sources",m.getSources());
        res.put("otherKW",otherKW);
        res.put("flag","true");
        String res_json=JSON.toJSONString(res);
        System.out.println(res_json);
        return res_json;
    }

数据库查询:

<select id="getKWInfo" resultType="com.example.demo.bean.KW">
        select *
        from kwinfo
        where KW=#{KW}
    </select>

4.点击相关热词,展示这个热词的信息

 xiangguan(name){
     console.log(name);
     this.KW=name;
     this.getInfo();
},

5.点击相关网页,跳到热词网页页面展示有关这个热词的网页

async getlianjie()
{
                
     this.$router.push({
     path: '/lianjie',
     query: {
           KW:this.KW,
     }    
    })
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值