echart宽度为100

// 显示
  <div v-show="showAllocationPay" ref="allocationPayRef" style="width:100%;height:275px;margin-top: 35px"></div>
              <img v-show="!showAllocationPay" src="@/assets/images/chart-default.png" style="height:310px;">

data () {
  return {
    showAllocationPay: false,
      allocationPay: null
}  
}

methods: {
       chartResize (chart) {
      setTimeout(function () {
        chart.resize()
        window.addEventListener('resize', _ => {
          chart.resize()
        })
      }, 200)
    },
      async getAllocationPay (category) {
  await  api.then(res => {
        this.showAllocationPay = true
            this.allocationPayOption.series[0].data = dealRechargeDataList
            this.allocationPayOption.series[1].data = dealConsumeDataList
            this.allocationPay = this.$echarts.init(this.$refs.allocationPayRef)
            this.allocationPay.setOption(this.allocationPayOption)
            this.chartResize(this.allocationPay)
})
}

}

  

posted @ 2022-06-29 10:28  everseven  阅读(124)  评论(0)    收藏  举报