vue echarts3


安装echarts

cnpm install --save vue-echarts-v3

新建一个一个通用的折线图组件  line.vue

<template>
    <div id="line">
    	<IEcharts :option="line" :style="style"></IEcharts>
    </div>
</template>

<script>
import IEcharts from 'vue-echarts-v3' // 导入IEcharts组件
export default {
  props: {
    obj: null
  },
  data () {
    return {
      line: {
        tooltip: {
          trigger: 'axis'
        },
        xAxis: { // 横坐标
          boundaryGap: false,
          data: this.obj.xAxis // 横坐标数据
        },
        yAxis: { // 纵坐标
        },
        series: [
          {
            name: '查询条数',
            type: 'line', // 图表类型
            data: this.obj.series // 纵坐标数据
          }
        ]
      },
      style: 'width:890px;height:500px;'
    }
  },
  components: {
    IEcharts// 声明组件
  }
}
</script>


父页面使用

<template>
<!--  :obj向子页面传值-->
  <detailedAll :obj="data"></detailedAll>
</template>

<script>
import line from '@/components/echarts/line.vue' // 引用line
export default {
  data () {
    return {
      data: null
    }
  },
  methods: {
// 图表
    detailedtab () {
      let that = this
      that.data = null
      let params = {}
      that.$api.get('###', params, function (req) {
        that.data = req.content
      })
    }
  },
  components: {
    detailedAll: line // 自定义组件
  }
}
</script>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值