完全没有报错,想破脑袋也没想到居然是在这么简单的地方出了问题,没设置宽高。还以为它会有默认高度,结果没设置宽高就不会显示。
<template>
<div class="container">
<div class="ct" ref="er">图标</div>
</div>
</template>
<script setup>
import { ref,onMounted} from 'vue';
import * as echarts from 'echarts';
const er = ref()
const option = ref({
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true
}
]
})
onMounted(()=>{
const myEr = echarts.init(er.value)
myEr.setOption(option.value)
})
</script>
<style lang="scss" scoped>
.container{
width: 100vw;
height: 100vh;
background-color: aquamarine;
}
.ct{
width: 500px;
height: 500px;
}
</style>