微信小程序echart导出图片

echarts版本5.1.0

用到的echarts组件是uni插件市场的echart组件

		initChart(canvas, width, height, canvasDpr) {
				let that = this;
				let ecComonnets = this.selectComponent('#uni-ec-canvas')
				console.log('ecComonnets', ecComonnets);

				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				canvas.setChart(chart)
                setTimeout(function() {
					console.log('asdad', ecComonnets);
					ecComonnets.$vm.canvasToTempFilePath({
						x: 0,
						y: 0,
						width: 290,
						height: 180,
						canvasId: 'myShareCanvas',
						success: function(res) {
							console.log('res.tempFilePath', res.tempFilePath);
							that.$store.commit('set_caseShareEchartPicList', [...that.caseShareEchartPicList, res.tempFilePath])
						},
						fail: function() {
							console.log("echarts生成失败")
						}
					})
				}, 1500)

				return chart
			},

关键代码是

微信小程序echart导出图片_第1张图片

微信小程序echart导出图片_第2张图片 

你可能感兴趣的:(uniapp(小程序),bug集锦,微信小程序,小程序)