小白白123、、 2021-06-24 15:03 采纳率: 0%
浏览 73

vue echarts后台获取数据

<template>
    <div class="map">
        <div ref="chart" style="width: 500; height: 400px;"></div>
        <div ref="chart1" style="width: 500; height: 400px;"></div>
    </div>

</template>
<script>
    import * as echarts from 'echarts';
    export default {
        name:"report",
        methods: {
            initChart(container, option) {
                const myChart = echarts.init(container);
                myChart.setOption(option);
            }
        },
        mounted() {
            let option = {
                title: {
                    text: 'ECharts 入门示例'
                },
                tooltip: {},
                xAxis: {
                    data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
                },
                yAxis: {},
                series: [{
                    name: '销量',
                    type: 'bar',
                    data: [5, 20, 36, 10, 10, 20]
                }]
            }
            
            this.initChart(this.$refs.chart, option)
            
            let option1 = {
                tooltip: {},
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: [150, 230, 224, 218, 135, 147, 260],
                    type: 'line'
                }]
            }
            
            this.initChart(this.$refs.chart1, option1)
        },
        created() {
                    const _this = this
                    this.axios.get("http://localhost:8089/threeproject/ConsultationmodeStatistics")
                        .then(function(response) {
                            _this.ConsultationmodeData = response.data
                        }).catch(function(error) {
                            console.log(error)
                        })
                }

    };
</script>
我该如何将虚数据替换成数据库mysql数据

  • 写回答

3条回答 默认 最新

  • 关注

    最好的办法是在后台返回一个json数据,然后用对象替换相关参数。

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作