feat: 暴露方法给父组件,用于获取图表图片数据
This commit is contained in:
@ -161,6 +161,25 @@ const initChart = () => {
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
// 暴露方法给父组件,用于获取图表图片数据
|
||||
defineExpose({
|
||||
getChartImage: () => {
|
||||
if (myChart.value) {
|
||||
return myChart.value.getDataURL({
|
||||
type: 'png',
|
||||
pixelRatio: 2,
|
||||
backgroundColor: '#fff'
|
||||
});
|
||||
}
|
||||
return null;
|
||||
},
|
||||
resizeChart: () => {
|
||||
if (myChart.value) {
|
||||
myChart.value.resize();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -190,6 +190,25 @@ watch([
|
||||
], () => {
|
||||
initChart();
|
||||
});
|
||||
|
||||
// 暴露方法给父组件,用于获取图表图片数据
|
||||
defineExpose({
|
||||
getChartImage: () => {
|
||||
if (chartInstance.value) {
|
||||
return chartInstance.value.getDataURL({
|
||||
type: 'png',
|
||||
pixelRatio: 2,
|
||||
backgroundColor: '#fff'
|
||||
});
|
||||
}
|
||||
return null;
|
||||
},
|
||||
resizeChart: () => {
|
||||
if (chartInstance.value) {
|
||||
chartInstance.value.resize();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(div) {
|
||||
|
||||
Reference in New Issue
Block a user