使用js引入echarts

1.首先在项目里打开cmd命令行

输入

vue3

npm add echarts

vue2

npm install echarts

2.然后在node_modules里就会看见一个echarts

这样的文件夹

3.在需要的页面里引入

 在mounted里写

            var myChart = echarts.init(document.getElementById('echartContainer'));
			// 绘制图表
			myChart.setOption({
			    title: { text: 'ECharts 入门示例' },
			    tooltip: {},
			    xAxis: {
			        data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
			    },
			    yAxis: {},
			    series: [{
					realtimeSort: true,
					barWidth: 14,
					barGap: 10,
					smooth: true,
					valueAnimation: true,
			        name: '销量',
			        type: 'bar',
			        data: [5, 20, 36, 10, 10, 20]
			    }]
			});
		

在html里面写

就可以了

你可能感兴趣的:(echarts,html)