echarts5 在vue3 中tooltip显示不出来

const unwarp = (obj) => obj && (obj.__v_raw || obj.valueOf() || obj);
        unwarp(this.chart).setOption(this.getOption());
<div id="app">
    <div id="chart-demo"></div>
</div>
<script>
import { createApp } from 'vue';
import * as echarts from "echarts";
const unwarp = (obj) => obj && (obj.__v_raw || obj.valueOf() || obj);
 
createApp({
    data(){
        return {
            chart:null
        }
    },
    mounted{
        let dom = document.getElementById("chart-demo");
        this.chart = echarts.init(dom);
        unwarp(this.chart).setOption(this.getOption());
    },
    methods:{
        getOption(){
            return {
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                tooltip:{},
                series: [{
                    data: [150, 230, 224, 218, 135, 147, 260],
                    type: 'line'
                }]
            };
        }
    }
}).mount("#app");
</script>

转载:https://blog.csdn.net/xy109/article/details/113869790

posted @ 2021-06-23 16:52  ___mouM  阅读(858)  评论(0编辑  收藏  举报