实现效果:


<template>
<div :id="id" :style="{ width: width , height: height }"></div>
</template>
<script lang="ts" setup>
interface Props{
id?:string,
type?:string,
width?:string,
height?:string,
barWidth?:string, //柱体宽度
color?:string[],
yname?:string, //y轴顶部字段
data?:number[][],
name?:string[], //x轴坐标数组
percentData?: string[], //柱体中显示的百分比
series?: string[], //图表顶部分类字段
legendData?: object
}
const props = withDefaults(defineProps<Props>(),{
id:'square',
width:'100%',
height:'500px',
color : ()=>{
return ["#ff9144", "#00cd98", "#0081fb"]
},
yname: '',
data: ()=>{
return [] },
name: ()=>{
return [] },
type:'0',
percentData: ()=>{
return [] },
series: ()=>{

本文档将介绍如何在Vue3项目中使用TypeScript封装Echarts组件,特别是绘制折线图。通过封装,可以实现图表组件的复用,并提高代码的可维护性。内容涵盖Echarts配置、Vue3组件化思想以及TypeScript类型定义。
最低0.47元/天 解锁文章
1750

被折叠的 条评论
为什么被折叠?



