国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

在vue中實(shí)現(xiàn)清除echarts上次保留的數(shù)據(jù)(親測有效)

瀏覽:12日期:2022-11-25 11:41:09

因?yàn)槲沂菍charts封裝好后,父組件只要傳遞值就可以進(jìn)行渲染。

但是點(diǎn)擊多次數(shù)據(jù)請求的時(shí)候echarts會(huì)多次渲染。如果試過

clear() 與setOption(this.options, true)沒用之后。可以試一下下面的方法。

首先是在父組件中對數(shù)據(jù)進(jìn)行請求,在賦值之前,先清空。

data里定義的三組echarts數(shù)據(jù)

在vue中實(shí)現(xiàn)清除echarts上次保留的數(shù)據(jù)(親測有效)

在axios發(fā)送請求后

先清空再賦值。

在vue中實(shí)現(xiàn)清除echarts上次保留的數(shù)據(jù)(親測有效)

補(bǔ)充知識:vue.js使用vue-echarts給柱形圖綁定點(diǎn)擊事件

我就廢話不多說了,大家還是直接看代碼吧~

<template> <div class='echarts'> <IEcharts :option='bar' :loading='loading' @ready='onReady' @click='onClick'></IEcharts> <button @click='doRandom'>Random</button> </div></template> <script type='text/babel'> import IEcharts from ’vue-echarts-v3/src/full.js’; export default { name: ’view’, components: { IEcharts }, props: { }, data: () => ({ loading: true, bar: { title: { text: ’ECharts Hello World’ }, tooltip: {}, xAxis: { data: [’Shirt’, ’Sweater’, ’Chiffon Shirt’, ’Pants’, ’High Heels’, ’Socks’] }, yAxis: {}, series: [{ name: ’Sales’, type: ’bar’, data: [5, 20, 36, 10, 10, 20] }] } }), methods: { doRandom() { const that = this; let data = []; for (let i = 0, min = 5, max = 99; i < 6; i++) { data.push(Math.floor(Math.random() * (max + 1 - min) + min)); } that.loading = !that.loading; that.bar.series[0].data = data; }, onReady(instance) { console.log(instance); }, onClick(event, instance, echarts) { console.log(arguments); } } };</script> <style scoped> .echarts { width: 400px; height: 400px; }</style>

以上這篇在vue中實(shí)現(xiàn)清除echarts上次保留的數(shù)據(jù)(親測有效)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 新郑市| 桃源县| 宾阳县| 宜君县| 巢湖市| 通州市| 罗甸县| 轮台县| 瑞丽市| 泾阳县| 康马县| 武陟县| 嘉祥县| 伊通| 宁都县| 绍兴县| 古浪县| 南康市| 岐山县| 晋中市| 老河口市| 达拉特旗| 中山市| 开阳县| 保亭| 阿克| 沙湾县| 双柏县| 永兴县| 鲁甸县| 巴东县| 上犹县| 周至县| 合川市| 灵川县| 金昌市| 池州市| 石渠县| 绥德县| 抚顺县| 巫溪县|