关于#前端#的问题:Echarts统一初始化了图标的一些元素,想要series不同的类型不同的boundrayGap

Echarts统一初始化了图标的一些元素,想要series不同的类型不同的boundrayGap。如series类型为line时,boundaryGap设置为false
    <div class="box">
        <div class="chart" id="Barline">div>
        <div class="chart" id="Pie">div>
    div>
div>
<script>
    const App = {
        data() {
            return {
                counter: 0
            }
        },
        mounted() {
            {
                this.initChart('#Barline')
                this.initChart('#Pie')
            }
            this.Barline()
        },
        methods: {
            initChart(name) {
                const chart = echarts.init(document.querySelector(name))
                const data = ['Babycar', 'Flydog', 'Mdd', 'Shidanli', 'Dangon']
                const option = {
                    textStyle: {
                        fontFamily: '字魂方方先锋体'
                    },
                    title: {
                        text: '折柱混合图(mixin)',
                        left: 'center',
                        top: '1%',
                    },
                    grid: {
                        top: '15%',
                        left: '3%',
                        right: '3%',
                        bottom: '6%',
                        containLabel: true
                    },
                    legend: [],
                    xAxis: {
                        type: 'category',
                        data,
                        boundaryGap: () => {
                            console.log(option)
                        },
                    },
                    yAxis: {
                        type: 'value',
                        interval: 50
                    }
                }
                chart.setOption(option)

            },
            Barline() {
                const chart = echarts.init(document.querySelector('#Barline'))
                const option = {
                    series: [
                        {
                            type: 'bar',
                            name: 'Score',
                            stack: 'total',
                            data: [100, 120, 130, 80, 100]
                        },
                        {
                            type: 'bar',
                            name: 'num',
                            data: [80, 100, 150, 150, 130]
                        },
                        {
                            type: 'line',
                            name: 'line',
                            stack: 'total',
                            data: [100, 120, 130, 80, 100]
                        }
                    ]
                }
                chart.setOption(option)
            }
        }
    };
    Vue.createApp(App).mount('#app');
script>
运行结果及报错内容
初始化对boundaryGap用箭头函数,回调函数进行传参判断,什么都获取不到

人家是个数组类型呀,
1.你可以在initChart 函数里面设一个变量获取值
2.或者当图表渲染后,再次设置属性