鍍金池/ 問(wèn)答/Python  網(wǎng)絡(luò)安全  HTML/ vue 結(jié)合django,問(wèn)題出現(xiàn)在熱力圖獲取不到數(shù)據(jù)

vue 結(jié)合django,問(wèn)題出現(xiàn)在熱力圖獲取不到數(shù)據(jù)

這是第一次結(jié)合vue和django實(shí)驗(yàn)的一個(gè)小作品。問(wèn)題出現(xiàn)在獲取不到數(shù)據(jù)。無(wú)法顯示在熱力圖中。請(qǐng)大神指點(diǎn)一二,謝謝!

這是一個(gè)vue 組件,代碼如下:

<template>

    <el-row type="flex" class="row-bg" justify="center">
      <div id="cal-heatmap"></div>
    </el-row>
    
</template>    

<script>
import CalHeatMap from "cal-heatmap";
export default {
  name: "home",
  filters: {
    date(val) {
      return moment(val).calendar();
    }
  },
  data() {
    return {
      input: "",
      // 當(dāng)前數(shù)據(jù)
      bookList: [],
      // 默認(rèn)每頁(yè)數(shù)量
      pageSize: 10,
      // 當(dāng)前頁(yè)碼
      currentPage: 1,
      // 默認(rèn)數(shù)據(jù)總數(shù)
      totalCount: 1000,
      // 搜索內(nèi)容
      query: "",
      //熱力圖
      heatmapValue:'',
    };
  },
  mounted: function() {
    this.showBooks();
    this.getHeatmapValue();
    this.calHeatMap();
  },
  methods: {
    calHeatMap() {
      var cal = new CalHeatMap();
      cal.init({
        itemSelector: "#cal-heatmap",
        domain: "month",
        data: this.heatmapValue,
        start: new Date(2017, 12),
        end: new Date(2018,12),
        cellSize: 9,
        range: 12,
        legend: [6, 10, 14, 20],
        legendHorizontalPosition: "right",
        itemName: ["張卡片", "張卡片"],
        subDomainDateFormat: function(date) {
          return moment(date).calendar();
        }
      });
      // return cal;
    },
    getHeatmapValue(){
      this.$http
        .get(
          "http://127.0.0.1:8000/api/heatmap_value",
          {
            params: {}
          },
          { emulateJSON: true }
        )
        .then(response => {
          var res = JSON.parse(response.bodyText);
          console.log(res);
          
          if (res.error_num == 0) {
            this.heatmapValue = res["heatmapValue"];
            console.log(this.heatmapValue)
          } else {
            this.$message.error("獲取數(shù)據(jù)失敗");
            console.log(res["msg"]);
          }
        });
    },
</script>
回答
編輯回答
懶洋洋

什么報(bào)錯(cuò)都不給 準(zhǔn)備我猜嗎

2018年4月29日 20:27