1.將Echarts的數據格式放在data return中;
2.自定義按鈕綁定一個單擊事件;
<button class="btn" @click="show()">隱藏按鈕</button>
3.將該圖標的格式傳入單擊事件函數中;
show(){ this.option.legend.selected={"語文":false,"數學":false,"英語":false,"生物":false,"化學":false,"物理":false}; //單擊后全部隱藏掉;在legend對象中添加selected屬性 //console.log(this.option); var hxt = echarts.init(document.getElementById("Linechart")); hxt.setOption(this.option); //重新加載圖片 }