vue中引入echarts

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21262357/article/details/88355075

cnpm install echarts --save

main.js中导入

import echarts from 'echarts'
Vue.prototype.$echarts=echarts

直接在组件中使用

let myChart = this.$echarts.init(document.getElementById('myChart'));
// 绘制图表
myChart.setOption({
	title: { text: '在Vue中使用echarts' },
	tooltip: {},
	xAxis: {
		data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
	},
	yAxis: {},
	series: [
		{
			name: '销量',
			type: 'bar',
			data: [5, 20, 36, 10, 10, 20]
		}
	]
});

猜你喜欢

转载自blog.csdn.net/qq_21262357/article/details/88355075