欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue中使用element ui的彈窗與echarts之間的問題詳解

 更新時間:2019年10月25日 10:48:12   作者:純白棒球帽  
這篇文章主要介紹了vue中使用element ui的彈窗與echarts之間的問題詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

今天項目中有個需求,就是在頁面中點擊一個圖標,彈出一個抽屜式的彈窗(彈窗是element UI的抽屜),彈窗里邊是echarts呈現(xiàn)的數(shù)據(jù),當我直接用echarts的時候,報錯dom沒有獲取到;

這就陷入疑惑,平時都是這樣獲取的,怎么今天就不行了呢,搜索了很多答案之后才知道,在剛進入頁面的時候抽屜是關(guān)閉的,那echarts不進行獲取dom,當點擊抽屜出來的時候,有個opened事件,在這個事件里邊進行echarts的初始化,執(zhí)行數(shù)據(jù);

<el-drawer
   title="分析圖表"
   :modal="false"
   :close-on-click-modal="false"
   :modal-append-to-body="false"
   size="600px"
   :visible.sync="dataVisible"
   @opened="opens"
  >
  <div ref="main" style="width: 100%;height:100%;"></div>
</el-drawer>

export default {
 data() {
  return {
   isColor: true,
   option1: {
    title: {
     text: '總資產(chǎn)占比分析',
     x: 'left'
    },
    tooltip: {
     trigger: 'item',
     formatter: '{a} <br/> : {c} (vvxyksv9kd%)'
    },
    legend: {
     orient: 'vertical',
     right: '10%',
     top: '35%',
     data: ['A', 'B', 'C', 'D']
    },
    series: [
     {
      name: '訪問來源',
      type: 'pie',
      radius: '70%',
      center: ['25%', '60%'],
      data: [
       { value: 335, name: 'A' },
       { value: 310, name: 'B' },
       { value: 234, name: 'C' },
       { value: 135, name: 'D' }
      ],
      label: {
       normal: {
        show: false,
        position: 'center'
       }
      }
     }
    ]
   },
}}
}
method:{
  opens(){
     this.$nextTick(() => {
      this.pie1()
   })
  },
  pie1(){
    this.$echarts.init(this.$refs.main).setOption(this.option1)
  }
}

這樣防止dom沒有渲染之前,數(shù)據(jù)先加載,主要是用了element ui彈窗的open方法,具體的為啥用這個方法,還需要研究下

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論