
父组件:
<barChartProfit :opt="avgProfit" />
import barChartProfit from "./components/barChartProfit";
data() {
return {
avgProfit: {
xData: ['2019', '2020', '2021', '2022', '2023'],
totalData: [30,30,30,30,30],
seriesData: [10,11,12,21,15]
}
}
}
子组件:
<template>
<div style="width: 100%;height: 100%;">
<ChartPanel ref="chart" :option="options" :style="opt.yAxisName ? 'height:calc(100% - 16px)' : ''"></ChartPanel>
</div>
</template>
<script>
import * as echarts from 'echarts'
import ChartPanel from '@/components/ChartPanel';
export default {
components: {
ChartPanel
},
props: {
opt: {
type: Object,
default() {
return {
}
}
}
},
data() {
return {
options: null
}
},
watch: {
opt: {
deep: t